Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle build task use outdated libraries, unable to upgrade directly #2986

Closed
gedeh opened this issue Oct 31, 2016 · 11 comments
Closed

Gradle build task use outdated libraries, unable to upgrade directly #2986

gedeh opened this issue Oct 31, 2016 · 11 comments

Comments

@gedeh
Copy link

gedeh commented Oct 31, 2016

When building Android app with latest SDK, support, and Google services, task gradle:assemble with latest gradle wrapper will fail to upgrade the SDK in hosted build agent.

  1. Unable to download due to missing accepted licences of SDK components
  2. Unable to update due to agent account restriction (moving downloaded updates into hosted agent SDK is failing)

My workaround to allow me build Android with latest SDK components:

  1. PowerShell task to download SDK zip to Build.SourcesDirectory
  2. PowerShell task to extract the SDK zip
  3. PowerShell task to upgrade the SDK components
  4. Copy licenses to SDK from repository
  5. Create local.properties to make gradle task use downloaded SDK instead of ones provided in hosted machine
@gedeh
Copy link
Author

gedeh commented Nov 1, 2016

More information:
Gradle version: 2.14.1

Error message on issue #1:
You have not accepted license agreement of the following SDK components:
[Google Repository, Android Support Repository, SDK Patch Applier v1]
Workaround:
Commit accepted licences locally to repository then using Copy files tasks to $(AndroidSDK)/licenses directory

Error message on issue #2:
Warning: an error occurred during installation: Failed to move away or delete existing target file
Workaround: As described in issue details

@madhurig
Copy link
Contributor

@gedeh: We normally see the "Not accepted license agreement" error when the required Android SDK or build tools or SDK components are not already installed on the hosted build VMs. Updating the SDK has helped resolve the issue for other customers. Which version of Android SDK are you using? Do you still need the workaround?

Thanks,
Madhuri

@gedeh
Copy link
Author

gedeh commented Jan 27, 2017

Hi @madhurig, thanks for your reply. Yes when this issue is raised the SDK components are not yet updated in hosted build VM as mentioned in my issue above. I am always try to use latest SDK and tools on my project. The main idea of the issue was if customer needs newer SDK than what installed in hosted build machine, the build should able to update to requested version seamlessly without have to use mentioned workaround, if possible.

I will try to modify my build to skip the workaround and believe it will work if hosted agent has the version. But I think will fail again once I update the components.

Thanks

@madhurig
Copy link
Contributor

@gedeh: The issue with automatically updating the requested version is the license agreement. We need a way for the user to agree to installing new components on the VM during their build. The amount of time it takes to download the component would also be a concern on hosted build. It will be a good enhancement.

@gedeh
Copy link
Author

gedeh commented Jan 27, 2017

@madhurig yes I agree if it should be classified as enhancement as not everyone might happy with auto downloading latest SDK components which consumes their hosted build agent build time resource. Also, there might be a concern about each of introduced license agreements.

I am happy if you decided to close this issue or leave it as is as enhancement request.

Thanks! 🥇

@dozgunyal
Copy link

Hi @gedeh , may i ask you to share your scripts here to help us until this issue is resolved?

@gedeh
Copy link
Author

gedeh commented Feb 22, 2017

Hi @dozgunyal, sorry being away lately, will attach the script soon tonight. Thanks!

@gedeh
Copy link
Author

gedeh commented Feb 22, 2017

hi @dozgunyal,

My build tasks to download, extract, update, and accept SDK licenses scripts content are inline:

PowerShell: Download Android SDK to sources directory
$url = "https://dl.google.com/android/android-sdk_r24.4.1-windows.zip"
$output = "$(Build.SourcesDirectory)\android-sdk_r24.4.1-windows.zip"
Write-Host "Download '$url' to '$output'"
$wc = New-Object System.Net.WebClient
$wc.DownloadFile($url, $output)

Extract file: Extract the downloaded SDK zip file
Archive file patterns: android-sdk_r24.4.1-windows.zip
Destination folder: $(Build.SourcesDirectory)

PowerShell: Create local.properties file so the build will use downloaded SDK
$sdkLocation = "$(Build.SourcesDirectory)\android-sdk-windows"
$sdkLocation = $sdkLocation.Replace("\","\\").Replace(":", "\:")
$content = "sdk.dir=$sdkLocation"
$file = "$(Build.SourcesDirectory)\local.properties"
Write-Host "Create file '$file' with content '$content'"
$content | Set-Content "$file"

Run cmd: Update local Android SDK
echo y | $(Build.SourcesDirectory)\android-sdk-windows\tools\android.bat update sdk --no-ui --all --filter tools,platform-tools,extra-google-m2repository,extra-google-google_play_services,extra-android-support

Copy files: Copy accepted local build Android SDK licenses
Source: $(Build.SourcesDirectory)\android-licenses\**
Target: $(Build.SourcesDirectory)\android-sdk-windows\licenses

note: I have the copy of accepted license files from my PC included in my code repository. the content of this folder are: android-sdk-license, android-sdk-preview-license, intel-android-extra-license. these files are never need to be updated so far

Then after SDK is in place, you can run gradle tasks to build, test, etc. If you need clarification of above script please shout, I am happy to help :)

Thanks,
Hendra

@davidkvc
Copy link

davidkvc commented Mar 6, 2017

thanks @gedeh
I am interested where did you find that link to download android SDK (https://dl.google.com/android/android-sdk_r24.4.1-windows.zip). I would like to know it in case I need to download different version.

@gedeh
Copy link
Author

gedeh commented Mar 8, 2017

Hi @DavizOWNS,

I get the link from Android SDK Manager window. See the details in Android SDK Manager Log window

@bryanmacfarlane bryanmacfarlane modified the milestone: TFS.vNext (onPrem) Mar 29, 2017
@davidstaheli davidstaheli removed this from the TFS.vNext (onPrem) milestone Apr 19, 2017
@davidstaheli davidstaheli assigned leantk and lkillgore and unassigned davidstaheli Jun 8, 2017
@madhurig
Copy link
Contributor

We are moving to a monthly cadence with image updates which alleviates this problem partly, we don't plan to add a feature in the Gradle task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants