Android Gradle build in Visual Studio Team Service

2020-04-23 04:58发布

I'm trying to create a working android gradle build definition in Visual Studio Team Services but I always get this error:

2016-10-09T07:30:56.0626848Z FAILURE: Build failed with an exception.
2016-10-09T07:30:56.0626848Z 
2016-10-09T07:30:56.0626848Z * What went wrong:
2016-10-09T07:30:56.0626848Z A problem occurred configuring project ':twuice_theme'.
2016-10-09T07:30:56.0636849Z > You have not accepted the license agreements of the following SDK components:
2016-10-09T07:30:56.0636849Z [Android SDK Platform 24, Android SDK Build-Tools 24.0.3].
2016-10-09T07:30:56.0636849Z Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
2016-10-09T07:30:56.0636849Z Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html
2016-10-09T07:30:56.0636849Z 
2016-10-09T07:30:56.0636849Z * Try:
2016-10-09T07:30:56.0636849Z Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
2016-10-09T07:30:56.0636849Z 
2016-10-09T07:30:56.0636849Z BUILD FAILED
2016-10-09T07:30:56.0636849Z 
2016-10-09T07:30:56.0636849Z Total time: 55.145 secs
2016-10-09T07:30:56.4528586Z [Error: C:\a\1\s\gradlew.bat failed with return code: 1]
2016-10-09T07:30:56.4718591Z ##[error]Error: C:\a\1\s\gradlew.bat failed with return code: 1
2016-10-09T07:30:56.4788582Z ##[section]Finishing: gradlew build

I searched but didn't find anything useful, so could somebody help me?

Thanks in advance

2条回答
够拽才男人
2楼-- · 2020-04-23 05:07

Thanks Mike for providing a workaround! The one issue that I ran into was that the builds were "partially successful" because of the error in step 2.

To get "successful" builds instead of "partially successful" builds, I replaced the three command line steps with one powershell step to execute an inline script:

New-Item -ItemType Directory -Path "C:\java\androidsdk\android-sdk\licenses"

New-Item -Name 'android-sdk-license' -ItemType File -Value '8933bad161af4178b1185d1a37fbf41ea5269c55' -Path "C:\java\androidsdk\android-sdk\licenses"

Get-Content "C:\java\androidsdk\android-sdk\licenses\android-sdk-license"
查看更多
forever°为你锁心
3楼-- · 2020-04-23 05:20

The method of fixing this error is defined here. Here is how you fix it within Visual Studio Team Services. The steps are

  1. Create "%ANDROID_HOME%\licenses" directory.
  2. Create "%ANDROID_HOME%\licenses\android-sdk-license" file.
  3. Output the created file's contents for verification.

Here's the details:

  1. Create a new "Build step" of type "Command Line" which is in the "Utilities" category.

    • Tool = mkdir
    • Arguments = "%ANDROID_HOME%\licenses"
  2. Create another "Command Line" build step.

    • Tool = echo
    • Arguments = |set /p="8933bad161af4178b1185d1a37fbf41ea5269c55" > "%ANDROID_HOME%\licenses\android-sdk-license"
    • Check "Continue on error" because this echo command will return 1.
  3. For verification, create a third "Command Line" build step
    • Tool = more
    • Arguments = "%ANDROID_HOME%\licenses\android-sdk-license"

Place these build steps in 1,2,3 order prior to executing your "Gradle" build step.

That's the good news. The bad news is that the gradle build step is failing during SDK installation with the error "Failed to move away or delete existing target file." So let me know if you figure that one out.

查看更多
登录 后发表回答