android: Xamarin.Android task cannot find NDK with latest Azure image(s)
Android application type
Classic Xamarin.Android (MonoAndroid12.0, etc.)
Affected platform version
Azure pipeline
Description
Making use of the Xamarin.Android task we have been able to build and deploy Xamarin.Android applications. New images were released which seems to have affected this task; the NDK path is no longer found when executing the “_ResolveMonoAndroidSdks” step resulting in a build failure.
Reviewing the latest releases for these images, I see there was work around NDK paths, symlinks, and environment variable changes. https://github.com/actions/virtual-environments/issues/5879 https://github.com/actions/virtual-environments/issues/5930
The image we’re using is macOS-latest, here are the old and new logs showing the “_ResolveMonoAndroidSdks” step resolving the NDK path:
Old working image (20220724.1)

New broken image (20220801.1)

Do we know if the Xamarin.Android task needs to be updated to reflect this?
Steps to Reproduce
- Make use of the Azure Pipeline Xamarin.Android task for a Xamarin.Android application using the
macOS-latestimage. - See the task eventually fails with
error XA5104: Could not locate the Android NDK. Please make sure the Android NDK is installed in the Android SDK Manager, or if using a custom NDK path, please ensure the $(AndroidNdkDirectory) MSBuild property is set to the custom path.
Did you find any workaround?
No response
Relevant log output
No response
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 3
- Comments: 85 (27 by maintainers)
Commits related to this issue
- [Xamarin.Android.Tools.AndroidSdk] Permit NDK r25 Context: https://github.com/xamarin/xamarin-android/issues/7233 Update `AndroidSdkBase.MaximumCompatibleNDKMajorVersion` to 25, so that NDK r25 is c... — committed to jonathanpeppers/xamarin-android-tools by jonathanpeppers 4 years ago
- [Xamarin.Android.Tools.AndroidSdk] Permit NDK r25 (#190) Context: https://github.com/xamarin/xamarin-android/issues/7233 Update `AndroidSdkBase.MaximumCompatibleNDKMajorVersion` to 25, so that ND... — committed to jonpryor/xamarin-android-tools by jonathanpeppers 4 years ago
There is definitely something up with the AzDO image. I downloaded the suspect
.dlland it is ancient:After I install my own
.pkgI get:I filed an issue here: https://github.com/actions/runner-images/issues/6038
Looking to find the right person to message at Microsoft internally.
Hey there, following the mitigation proposed in this thread, I’ve added this task prior to my Android build task and at least the NDK is now present.
This might not be an elegant permanent solution, since as @GreatBarrier86 stated, I also don’t understand why 21.4.7075529 is not found automatically. However, this could help unblock those failing pipelines in the meantime at least.
@Maxgamerboy1, I’m leaving this here for anyone else that happens to run across this same question. You can pass in MSBuild arguments to sign the APK file, regardless of whether its your key or not. Maybe it will help someone in the future because i did need to research how to do this.
/p:OutputPath=$(build.binariesdirectory)/$(BuildConfiguration)/$(TestOutputFolder) /t:SignAndroidPackage /p:AndroidKeyStore=true /p:AndroidSigningKeyAlias=$(KeystoreAlias) /p:AndroidSigningKeyPass=$(CertificatePassword) /p:AndroidSigningKeyStore=$(Build.SourcesDirectory)/MyKeystore.file /p:AndroidSigningStorePass=$(CertificatePassword)Taken from here: https://www.jenx.si/2020/04/05/xamarin-forms-developers-how-to-sign-android-apk/
Ok, so I think we’ve solved this one – the
macos-12image has Xamarin.Android 13.x, which supports up to Android NDK 24.Let me know if I missed anything outstanding here, thanks!
@salgiza sure! Although, see my response here https://github.com/xamarin/xamarin-android/issues/7233#issuecomment-1234315475 the issue is relating more to the build image itself rather than the task used to build.
to switch over, in your case, it should look something like this;
@jtorvald you can email at the address on my GitHub profile, thanks.
@Maxgamerboy1, one thing I noticed, and I’m not sure what I should be using here, but the Xamarin.Android step’s msbuild line shows
/t:PackageForAndroidinstead of/t:SignAndroidPackage. My next step after this is theAndroid signingtask, so I’m not sure which to use. For now, i’m going with `/t:PackageForAndroid’ to mimic what the original task had.@Maxgamerboy1, i’m not sure i agree that is unsupported, but i have no inside knowledge. According to GitHub, the Xamarin.Android task was just updated 2 months ago. I’m not sure if it’s really “unsupported”. Read what i wrote up here: https://github.com/xamarin/xamarin-android/issues/7233#issuecomment-1233474937
@Maxgamerboy1, any reason you’re using the MSBuild task over the XamarinAndroid one? just curious myself. I’d like to use whichever one is recommended.
@Maxgamerboy1 can you use this to get a
.binlogof your build:Then save this file as an artifact, and share it?
You might consider using the plain
MSBuildyaml task instead ofXamarinAndroid. I’m not sure who created it, or if it is maintained. It seems like theMSBuildtask would do everything and you just need to use the-t:SignAndroidPackagetarget?@rubeonline if they dropped an Android NDK from the image, and then there isn’t an NDK that this old version of Xamarin.Android supports – you’ll probably have an issue. In that case you may need to install an older NDK yourself, or newer Xamarin.Android.
Ok, this log message is a bit different than what I’m seeing!
Mine is also using
XamarinAndroidVersion: 13.0.0-0, which it downloaded and installed.It seems like the bots should still have r23 and r24, can you add some
lscommands to a build to find out if they are there?