Closed mikhailkoliada closed 7 months ago
For those who are struggling with this in .NET MAUI, run this command and you're good to go:
dotnet build -t:InstallAndroidDependencies -f:net8.0-android -p:AcceptAndroidSDKLicenses=True -p:AndroidSdkPath="/usr/local/lib/android/sdk/"
For those who are struggling with this in .NET MAUI, run this command and you're good to go:
dotnet build -t:InstallAndroidDependencies -f:net8.0-android -p:AcceptAndroidSDKLicenses=True -p:AndroidSdkPath="/usr/local/lib/android/sdk/"
@Alexey-Ayupov @mikhailkoliada somehow we're getting non-predictable results with this. We configured it like this in Azure DevOps:
- task: DotNetCoreCLI@2
displayName: Install Android dependencies
inputs:
command: build
projects: "${{ parameters.project }}"
arguments: >
-t:InstallAndroidDependencies
-f:net${{ variables.DOTNET_VERSION }}-android
-p:AcceptAndroidSDKLicenses=True
-p:AndroidSdkPath="/usr/local/lib/android/sdk/"
-o:$(Build.ArtifactStagingDirectory)
This does result in a predictable command being run:
/opt/hostedtoolcache/dotnet/dotnet build /home/vsts/work/1/s/./src/MyNamespace.App/MyNamespace.App.csproj -dl:CentralLogger,"/home/vsts/work/_tasks/DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b/2.232.0/dotnet-build-helpers/Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"*ForwardingLogger,"/home/vsts/work/_tasks/DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b/2.232.0/dotnet-build-helpers/Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" -t:InstallAndroidDependencies -f:net8.0-android -p:AcceptAndroidSDKLicenses=True -p:AndroidSdkPath=/usr/local/lib/android/sdk/ -o:/home/vsts/work/1/a
However more than half of the time we get a failed run:
/opt/hostedtoolcache/dotnet/dotnet build /home/vsts/work/1/s/./src/MyNamespace.App/MyNamespace.App.csproj -dl:CentralLogger,"/home/vsts/work/_tasks/DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b/2.232.0/dotnet-build-helpers/Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"*ForwardingLogger,"/home/vsts/work/_tasks/DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b/2.232.0/dotnet-build-helpers/Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" -t:InstallAndroidDependencies -f:net8.0-android -p:AcceptAndroidSDKLicenses=True -p:AndroidSdkPath=/usr/local/lib/android/sdk/ -o:/home/vsts/work/1/a
MSBuild version 17.8.3+195e7f5a3 for .NET
Determining projects to restore...
Restored [several projects - edited] (in 1.08 sec).
##[warning]/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/tools/Xamarin.Android.Tooling.targets(70,5): Warning XA5300: The Android SDK directory could not be found. Install the Android SDK by following the instructions at: https://aka.ms/dotnet-android-install-sdk
To use a custom SDK path for a command line build, set the 'AndroidSdkDirectory' MSBuild property to the custom path.
/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/tools/Xamarin.Android.Tooling.targets(70,5): warning XA5300: The Android SDK directory could not be found. Install the Android SDK by following the instructions at: https://aka.ms/dotnet-android-install-sdk [/home/vsts/work/1/s/src/MyNamespace.App/MyNamespace.App.csproj::TargetFramework=net8.0-android]
/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/tools/Xamarin.Android.Tooling.targets(70,5): warning XA5300: To use a custom SDK path for a command line build, set the 'AndroidSdkDirectory' MSBuild property to the custom path. [/home/vsts/work/1/s/src/MyNamespace.App/MyNamespace.App.csproj::TargetFramework=net8.0-android]
##[warning]/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/targets/Microsoft.Android.Sdk.Tooling.targets(31,5): Warning XARAT7003: System.ArgumentNullException: Value cannot be null. (Parameter 'path1')
at System.ArgumentNullException.Throw(String paramName)
at System.IO.Path.Combine(String path1, String path2, String path3)
at Xamarin.Android.Tasks.ResolveAndroidTooling.RunTask()
at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /mnt/vss/_work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 25
/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/targets/Microsoft.Android.Sdk.Tooling.targets(31,5): warning XARAT7003: System.ArgumentNullException: Value cannot be null. (Parameter 'path1') [/home/vsts/work/1/s/src/MyNamespace.App/MyNamespace.App.csproj::TargetFramework=net8.0-android]
/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/targets/Microsoft.Android.Sdk.Tooling.targets(31,5): warning XARAT7003: at System.ArgumentNullException.Throw(String paramName) [/home/vsts/work/1/s/src/MyNamespace.App/MyNamespace.App.csproj::TargetFramework=net8.0-android]
/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/targets/Microsoft.Android.Sdk.Tooling.targets(31,5): warning XARAT7003: at System.IO.Path.Combine(String path1, String path2, String path3) [/home/vsts/work/1/s/src/MyNamespace.App/MyNamespace.App.csproj::TargetFramework=net8.0-android]
/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/targets/Microsoft.Android.Sdk.Tooling.targets(31,5): warning XARAT7003: at Xamarin.Android.Tasks.ResolveAndroidTooling.RunTask() [/home/vsts/work/1/s/src/MyNamespace.App/MyNamespace.App.csproj::TargetFramework=net8.0-android]
/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/targets/Microsoft.Android.Sdk.Tooling.targets(31,5): warning XARAT7003: at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /mnt/vss/_work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs:line 25 [/home/vsts/work/1/s/src/MyNamespace.App/MyNamespace.App.csproj::TargetFramework=net8.0-android]
##[error]/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): Error MSB4044: The "InstallAndroidDependencies" task was not given a value for the required parameter "AndroidSdkPath".
/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): error MSB4044: The "InstallAndroidDependencies" task was not given a value for the required parameter "AndroidSdkPath". [/home/vsts/work/1/s/src/MyNamespace.App/MyNamespace.App.csproj::TargetFramework=net8.0-android]
Build FAILED.
and when we get a successful run, this is the log of the task:
/opt/hostedtoolcache/dotnet/dotnet build /home/vsts/work/1/s/./src/MyNamespace.App/MyNamespace.App.csproj -dl:CentralLogger,"/home/vsts/work/_tasks/DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b/2.232.0/dotnet-build-helpers/Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"*ForwardingLogger,"/home/vsts/work/_tasks/DotNetCoreCLI_5541a522-603c-47ad-91fc-a4b1d163081b/2.232.0/dotnet-build-helpers/Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" -t:InstallAndroidDependencies -f:net8.0-android -p:AcceptAndroidSDKLicenses=True -p:AndroidSdkPath=/usr/local/lib/android/sdk/ -o:/home/vsts/work/1/a
MSBuild version 17.8.3+195e7f5a3 for .NET
Determining projects to restore...
Restored [several projects - edited] (in 1.08 sec).
##[warning]/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): Warning : Android component "tools" is obsolete, please install "cmdline-tools"
/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): warning : Android component "tools" is obsolete, please install "cmdline-tools" [/home/vsts/work/1/s/src/MyNamespace.App/MyNamespace.App.csproj::TargetFramework=net8.0-android]
##[warning]/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): Warning : Trying to fallback to "tools"...
/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): warning : Trying to fallback to "tools"... [/home/vsts/work/1/s/src/MyNamespace.App/MyNamespace.App.csproj::TargetFramework=net8.0-android]
##[warning]/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): Warning : Dependency `platforms;android-34` should have been installed but could not be resolved. You can attempt to install it with: `/usr/local/lib/android/sdk/cmdline-tools/latest/bin/sdkmanager --install "platforms;android-34"`
/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): warning : Dependency `platforms;android-34` should have been installed but could not be resolved. You can attempt to install it with: `/usr/local/lib/android/sdk/cmdline-tools/latest/bin/sdkmanager --install "platforms;android-34"` [/home/vsts/work/1/s/src/MyNamespace.App/MyNamespace.App.csproj::TargetFramework=net8.0-android]
##[warning]/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): Warning : Dependency `build-tools;34.0.0` should have been installed but could not be resolved. You can attempt to install it with: `/usr/local/lib/android/sdk/cmdline-tools/latest/bin/sdkmanager --install "build-tools;34.0.0"`
/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): warning : Dependency `build-tools;34.0.0` should have been installed but could not be resolved. You can attempt to install it with: `/usr/local/lib/android/sdk/cmdline-tools/latest/bin/sdkmanager --install "build-tools;34.0.0"` [/home/vsts/work/1/s/src/MyNamespace.App/MyNamespace.App.csproj::TargetFramework=net8.0-android]
##[warning]/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): Warning : Dependency `platform-tools` should have been installed but could not be resolved. You can attempt to install it with: `/usr/local/lib/android/sdk/cmdline-tools/latest/bin/sdkmanager --install "platform-tools"`
/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): warning : Dependency `platform-tools` should have been installed but could not be resolved. You can attempt to install it with: `/usr/local/lib/android/sdk/cmdline-tools/latest/bin/sdkmanager --install "platform-tools"` [/home/vsts/work/1/s/src/MyNamespace.App/MyNamespace.App.csproj::TargetFramework=net8.0-android]
Build succeeded.
/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): warning : Android component "tools" is obsolete, please install "cmdline-tools" [/home/vsts/work/1/s/src/MyNamespace.App/MyNamespace.App.csproj::TargetFramework=net8.0-android]
/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): warning : Trying to fallback to "tools"... [/home/vsts/work/1/s/src/MyNamespace.App/MyNamespace.App.csproj::TargetFramework=net8.0-android]
/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): warning : Dependency `platforms;android-34` should have been installed but could not be resolved. You can attempt to install it with: `/usr/local/lib/android/sdk/cmdline-tools/latest/bin/sdkmanager --install "platforms;android-34"` [/home/vsts/work/1/s/src/MyNamespace.App/MyNamespace.App.csproj::TargetFramework=net8.0-android]
/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): warning : Dependency `build-tools;34.0.0` should have been installed but could not be resolved. You can attempt to install it with: `/usr/local/lib/android/sdk/cmdline-tools/latest/bin/sdkmanager --install "build-tools;34.0.0"` [/home/vsts/work/1/s/src/MyNamespace.App/MyNamespace.App.csproj::TargetFramework=net8.0-android]
/opt/hostedtoolcache/dotnet/packs/Microsoft.Android.Sdk.Linux/34.0.52/tools/Xamarin.Installer.Common.targets(12,3): warning : Dependency `platform-tools` should have been installed but could not be resolved. You can attempt to install it with: `/usr/local/lib/android/sdk/cmdline-tools/latest/bin/sdkmanager --install "platform-tools"` [/home/vsts/work/1/s/src/MyNamespace.App/MyNamespace.App.csproj::TargetFramework=net8.0-android]
5 Warning(s)
0 Error(s)
Time Elapsed 00:00:05.67
Info: Azure Pipelines hosted agents have been updated and now contain .Net 5.x SDK/Runtime along with the older .Net Core version which are currently lts. Unless you have locked down a SDK version for your project(s), 5.x SDK might be picked up which might have breaking behavior as compared to previous versions. You can learn more about the breaking changes here: https://docs.microsoft.com/en-us/dotnet/core/tools/ and https://docs.microsoft.com/en-us/dotnet/core/compatibility/ . To learn about more such changes and troubleshoot, refer here: https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
Finishing: Install Android dependencies
https://github.com/actions/runner-images/blob/a89e382279a91339e9afe0d7477a8bb1f087670f/images/ubuntu/Ubuntu2204-Readme.md?plain=1#L258 mentioned that platform tools 34.0.5 is included in this image.
We use /usr/local/lib/android/sdk/platform-tools/adb
, and I see that version 34.0.5 still has it in the platform-tools
dir, but now we are getting the error
System.ComponentModel.Win32Exception (2): An error occurred trying to start process '/usr/local/lib/android/sdk/platform-tools/adb' with working directory '/home/runner/work/out'. No such file or directory
Is this temporary because of the migration, or do we need to install adb ourselves?
For those who are struggling with this in .NET MAUI, run this command and you're good to go:
dotnet build -t:InstallAndroidDependencies -f:net8.0-android -p:AcceptAndroidSDKLicenses=True -p:AndroidSdkPath="/usr/local/lib/android/sdk/"
Also successed with temporary solution below.
- name: Set Up Android tools
run: |
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager \
--sdk_root=$ANDROID_SDK_ROOT \
"platform-tools"
- name: Build
run: |
dotnet build <project> \
-f:net8.0-android
For .NET Xamarin, this is what I did for a windows-2022 pipeline to fix it.
Add this Command Line task before your Xamarin.Android task
- script: |
C:\Android\android-sdk\cmdline-tools\latest\bin\sdkmanager "platforms;android-28"
displayName: 'Install Android API 28'
Note: C:\Program Files (x86)\Android\android-sdk\tools
directory was removed it seems and has produced another issue where I get a runtime crash error (see my second comment further down)
Also successed with temporary solution below.
- name: Set Up Android tools run: | ${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager \ --sdk_root=$ANDROID_SDK_ROOT \ "platform-tools" - name: Build run: | dotnet build <project> \ -f:net8.0-android
Thanks a lot, @DosangGu! This was what worked for me. The solution described by @ysmoradi in https://github.com/actions/runner-images/issues/8952#issuecomment-1882923510 didn't work, because I get the error described by @hansmbakker in https://github.com/actions/runner-images/issues/8952#issuecomment-1884552362 every single time ("The Android SDK directory could not be found").
To @mikhailkoliada or whomever it may concern: This unexpected change cost me several hours of work. Firstly, it would be great if there were pipeline warnings (visible on the main build result page) for a long sunset period before such changes occur, to increase the chance that devs pick this up and can prepare for it, instead of finding out only when trying to build a (possibly urgent) app update. Secondly, it would be great if the official solution actually worked. 😅 We are after all paying quite a bit for the privilege of using Azure Pipelines...
Commenting because Maui issues redirected me here:
Would someone know how the fix for a linux agent on azure devops woud look like?
The Android SDK Platform-Tools
got removed completely. Was this on purpose? it was only announced that old APIs and tools are to be removed. The platform-tools were up2date and should IMHO not be removed. We are targeting API 32 through platform-tools 34 and this change broke all our Android builds...
We combined the fixes since we have Windows and Ubuntu runners (expects the runner to be passed as inputs.runner
):
...
on:
workflow_call:
inputs:
...
runner:
default: ubuntu-latest
type: string
description: "OS of the runner: ubuntu-latest (default) or windows-latest."
...
jobs:
build:
runs-on: ${{ inputs.runner }}
steps:
...
- name: Set Up Android tools (windows runner only)
if: ${{ startswith(inputs.runner, 'windows') }}
run: C:\Android\android-sdk\cmdline-tools\latest\bin\sdkmanager "platform-tools"
- name: Set Up Android tools (non-windows runner only)
if: ${{ !startswith(inputs.runner, 'windows') }}
run: |
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager \
--sdk_root=$ANDROID_SDK_ROOT \
"platform-tools"
...
@Falco20019 would https://github.com/android-actions/setup-android help with installing/finding the sdkmanager or is that broken too?
@Hanmac I would assume that this should still work since according to the description, it should install the SDK and platform-tools even if nothing was pre-installed.
I can give it a try later today, but just calling the already installed sdkmanager was the quickest solution since we have to get actions approved in the organization first for them to be usable. I can compare the time it takes using the action. Using the sdkmanager, it currently adds only 12 seconds to the build time.
For .NET Xamarin, this is what I did for a windows-2022 pipeline to fix it.
Add this Command Line task before your Xamarin.Android task
- script: | C:\Android\android-sdk\cmdline-tools\latest\bin\sdkmanager "platforms;android-28" C:\Android\android-sdk\cmdline-tools/latest/bin/sdkmanager "build-tools;28.0.3" displayName: 'Install Android API 28'
Getting this warning that I did not notice after fixing the failing pipeline.
C:\Program Files (x86)\Android\android-sdk\tools\proguard\proguard-android.txt(0,0): Warning XA4304: ProGuard configuration file 'C:\Program Files (x86)\Android\android-sdk\tools\proguard\proguard-android.txt' was not found.
Has Proguard been removed or moved? How can I fix this?
This is causing the built APK to crash when rendering animations from the AirBnb Lottie package.
Azure DevOps
OK, this is nasty. I'm running dotnet workload restore MySolution.sln
just before building my solution in Azure Pipelines ubuntu-latest, and even though getting this:
[error]/usr/share/dotnet/packs/Microsoft.Android.Sdk.Linux/33.0.95/tools/Xamarin.Android.Tooling.targets(70,5): error XA5300: The Android SDK directory could not be found. Install the Android SDK by following the instructions at: https://aka.ms/dotnet-android-install-sdk [/home/vsts/work/1/s/src/AvaloniaSyncer.Android/AvaloniaSyncer.Android.csproj]
I assume that restoring workloads should care about installing the required Android SDK and everything. Why is the Android application different from any other when it comes to building? If it requires something, install it.
That's common sense, isn't it?
BTW, none of the solutions above applies to my scenario because I'm using Nuke build. I'm building withi this code: https://github.com/SuperJMN/AvaloniaSyncer/blob/8dbcd7de17e7b890a5071a5accdcdb674dafa7bf/build/Build.cs#L40
Please, fix this ASAP.
@SuperJMN The path to the SDK is /usr/local/lib/android/sdk, you should be able to call it also there as Shell command:
/usr/local/lib/android/sdk/cmdline-tools/latest/bin/sdkmanager --sdk_root=/usr/local/lib/android/sdk "platform-tools"
I also find it frustrating that Android builds have some more dependencies not dealt with by the workload. There is a dotnet global tool that helps with setting up prequisites that we use on our machines. But was not necessary on the runners so far: https://github.com/Redth/dotnet-maui-check
Anyone have a solution for the C:\Program Files (x86)\Android\android-sdk\tools
directory now missing in windows-2022 image?
Edit: This is what my local computer has, and allows a local build to be succesful. This does not exist anymore in the windows image.
Need the Proguard folder to exist.
My Xamarin Forms Android build now gets this warning:
C:\Program Files (x86)\Android\android-sdk\tools\proguard\proguard-android.txt(0,0): Warning XA4304: ProGuard configuration file 'C:\Program Files (x86)\Android\android-sdk\tools\proguard\proguard-android.txt' was not found.
Which results in a run-time crash of the built APK 😨
@Blue101black According to https://developer.android.com/build/shrink-code ProGuard was replaced by R8. You might need to adjust your tooling accordingly.
Your screenshot still shows a proguard folder. Did you create it manually?
I am having to change my Xamarin.Forms application to target a later version of the Android SDK because of this removal. I've changed nothing other than the "Target Android version", from "API Level 29" to "API Level 34". The vm image is "windows-2022" and the XamarinAndroid@1 step fails with "An exception has occurred in the compiler (1.8.0_392). Please file a bug against the Java compiler via the Java bug reporting page"
I've changed the build yml to use the "windows-2019" vm image and that hangs on the same step. After an hour, DevOps cancels the build
Don't know where I go from here, any suggestions will be much appreciated
@cjp666 you can try what I did, see my first response on this thread.
Do that step just before your xamarin android task, do it as a command line task.
Change API 28, to 29 for your case.
Once it succeeds, check the run and see if their is a warning for proguard missing. That may cause runtime crashes which I am currently figuring out myself.
@Blue101black you are a star, thank you
Adding
As the step before my XamarinAndroid@1 step sorted it for me
Need to run it now and see if there are any proguard errors
@SuperJMN The path to the SDK is /usr/local/lib/android/sdk, you should be able to call it also there as Shell command:
/usr/local/lib/android/sdk/cmdline-tools/latest/bin/sdkmanager --sdk_root=/usr/local/lib/android/sdk "platform-tools"
I also find it frustrating that Android builds have some more dependencies not dealt with by the workload. There is a dotnet global tool that helps with setting up prequisites that we use on our machines. But was not necessary on the runners so far: https://github.com/Redth/dotnet-maui-check
I'm sorry. I can't understand what you suggest. This issue mentions that "Android SDKs and tools" are deleted, so no longer available as part of the runner images. That is breaking my Android builds. So, how to install those tools manually to make my Android builds work again?
I guess it's a matter of installing it manually, but how?
Thank you!
@Blue101black you are a star, thank you
Adding
- script: | C:\Android\android-sdk\cmdline-tools\latest\bin\sdkmanager "platforms;android-29" displayName: 'Install Android API 29'
As the step before my XamarinAndroid@1 step sorted it for me
Need to run it now and see if there are any proguard errors
What's the equivalent in "powershell" so it can run in whatever image? Thanks!
@Blue101black I'm not getting any proguard errors, everything runs fine for me
@SuperJMN I think in the powershell script you should just be able to run C:\Android\android-sdk\cmdline-tools\latest\bin\sdkmanager.exe "platforms;android-29"
@SuperJMN This will not work for you as it's for Windows. According to your error message you use Ubuntu, therefore needing Shell, not PowerShell (and corresponding paths).
They did not mention that Android SDKs and tools
are removed. Only OLD are removed. But they seem to have also deleted one of the tools accidentally (platform-tools) which is needed by most of us... So the only thing missing for you is to install them.
I never worked with Nuke, but I would assume, that it should look something like this for you:
Target RestoreAndroidPlatformTools => td => td
.Executes(() =>
{
StartShell(@"/usr/local/lib/android/sdk/cmdline-tools/latest/bin/sdkmanager --sdk_root=/usr/local/lib/android/sdk \"platform-tools\"").AssertZeroExitCode();
});
Just make sure to have RestoreAndroidPlatformTools
as dependency before you try to run your build. That's what I tried to tell you at https://github.com/actions/runner-images/issues/8952#issuecomment-1892508293 but due to writing from my smartphone, giving you a full example was hard.
@Blue101black you are a star, thank you
Adding
- script: | C:\Android\android-sdk\cmdline-tools\latest\bin\sdkmanager "platforms;android-29" displayName: 'Install Android API 29'
As the step before my XamarinAndroid@1 step sorted it for me
Need to run it now and see if there are any proguard errors
Thanks, that fixed my Xamarin Android build issue!
How does this relate to App Center? Does it use the same agent? I noticed builds with Android sdk < 31 don't work there as well.
Cleaned up.
Success with this solution (GitHub Actions)
- name: Setup Android SDK 27, 28, 29 and 30
uses: android-actions/setup-android@v3
with:
cmdline-tools-version: 9123335
- run: sdkmanager tools "platforms;android-27" "platforms;android-28" "platforms;android-29" "platforms;android-30"
Is this temporary because of the migration, or do we need to install adb ourselves?
@shichen85, did you ever receive an answer to your question?
I'm also seeing /usr/local/lib/android/sdk/platform-tools/adb: No such file or directory
.
Is this temporary because of the migration, or do we need to install adb ourselves?
@shichen85, did you ever receive an answer to your question?
I'm also seeing
/usr/local/lib/android/sdk/platform-tools/adb: No such file or directory
.
I don't think I have gotten a reply. I ended up installing adb myself as many other suggested with something similar to:
- name: Set Up Android tools (non-windows runner only)
if: ${{ !startswith(inputs.runner, 'windows') }}
run: |
${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager \
--sdk_root=$ANDROID_SDK_ROOT \
"platform-tools"
Is this temporary because of the migration, or do we need to install adb ourselves?
@shichen85, did you ever receive an answer to your question?
I'm also seeing
/usr/local/lib/android/sdk/platform-tools/adb: No such file or directory
.
I would settle with using https://github.com/android-actions/setup-android to avoid future breaks. We also started with the workaround but this is easier and works for different runners (windows and ubuntu).
Breaking changes
Android SDK & tools v19 through v30 will be removed from Windows 2019 image. Android SDK & tools v27 through v30 will be removed from Windows 2022 and all Ubuntu and macOS images.
Target date
The images rollout process will start on January 8 and take 3-4 days.
The motivation for the changes
We would like to remove some obsolete versions and free up more disk space on runner agents.
Possible impact
If your workflows or pipelines depend on these older version of components, they may be broken.
Platforms affected
Runner images affected
Mitigation ways
Nothing specific is required. All the components can still be installed using Android's sdkmanager.