You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Xamarin.Android task cannot find NDK with latest Azure image(s) #7233
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.
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-latest image.
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.
Instead of the suggested mitigation of installing r21, is there a way to change the project to just use the latest version? I'm obviously having the same problem too.
@jonathanpeppers, there's something here i dont understand. I dont think we're specifying the required NDK version in our manifest or csproj file, so what's causing it to use r21 specifically instead of just $LatestVersion.
"/Users/runner/work/8/s/Mobile/CPSMobile/CPSMobile.Android/CPSMobile.Android.csproj" (PackageForAndroid target) (1) ->
(_BuildApkEmbed target) ->
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1954,3): 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. [/Users/runner/work/8/s/Mobile/CPSMobile/CPSMobile.Android/CPSMobile.Android.csproj]
@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: #7233 (comment)
@GreatBarrier86 no real reason, i'm seeing Pepper's builds making use of it, and with the revelation that we don't know who is maintaining that task, I think it's a smart move to hop over the MSBuild task
I don't think I use the XamarinAndroid .yaml task, where did you see that? If someone is working on lately, it isn't the Xamarin.Android team, so I'm not sure about its status.
Personally, I don't see what value it has over the regular MSBuild task. If there is some value, we should just put that logic in Xamarin.Android/.NET 6 instead?
Could someone post an example of how the MSBuild task should be configured to get the same result as this basic XamarinAndroid task?
We are having the same problem and I don't really mind using one or the other as long as it works, but all the docs for Azure DevOps use the XamarinAndroid task, and I'm totally unfamiliar with the MSBuild task 😢
Thanks a lot @Maxgamerboy1 , with all the messages in the thread, I had missed the one that said that changing the vmImage from macos-latest to macos-12 should fix the problem. Seeing the comments from @jonathanpeppers, though, I decided to do both (change the vmImage, and migrate from the XamarinAndroid task to MSBuild), and our pipeline is working again!
@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:PackageForAndroid instead of /t:SignAndroidPackage. My next step after this is the Android signing task, 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 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.
Activity
jonathanpeppers commentedon Aug 4, 2022
Did this start failing like last night?
I have a build yesterday that did:
https://dev.azure.com/jonathanpeppers/boots/_build/results?buildId=31&view=logs&j=a82d9e72-1de4-5bd6-c188-90296135479e&t=65080fd3-055e-56ae-0221-9a17a9cb5386&l=365
It is
macOS-latest:https://github.com/jonathanpeppers/boots/blob/7bf7e0875d8e4a19c3c51559521d7d0f1aa15f89/azure-pipelines.yml#L35
jonathanpeppers commentedon Aug 4, 2022
Started a new one, let's see what it does: https://dev.azure.com/jonathanpeppers/boots/_build/results?buildId=33&view=results
jonathanpeppers commentedon Aug 4, 2022
I think it also worked: https://dev.azure.com/jonathanpeppers/boots/_build/results?buildId=33&view=logs&j=a82d9e72-1de4-5bd6-c188-90296135479e&t=65080fd3-055e-56ae-0221-9a17a9cb5386&l=365
thomasphillipsgb commentedon Aug 4, 2022
Thanks for the response! Our builds started failing this morning, ones running yesterday were still using the old image, due to the staggered rollout.
I do see your build is using MSBuild directly, whereas I'm using this badger for building my Xamarin Android project
https://docs.microsoft.com/en-gb/azure/devops/pipelines/tasks/build/xamarin-android?view=azure-devops
jonathanpeppers commentedon Aug 4, 2022
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?jonathanpeppers commentedon Aug 4, 2022
Mine is also using
XamarinAndroidVersion: 13.0.0-0, which it downloaded and installed.GreatBarrier86 commentedon Aug 4, 2022
Instead of the suggested mitigation of installing r21, is there a way to change the project to just use the latest version? I'm obviously having the same problem too.
@jonathanpeppers, there's something here i dont understand. I dont think we're specifying the required NDK version in our manifest or csproj file, so what's causing it to use r21 specifically instead of just $LatestVersion.
_ResolveMonoAndroidSdks:
MonoAndroid Tools: /Library/Frameworks/Xamarin.Android.framework/Libraries/xbuild/Xamarin/Android/
Android Platform API level: 31
TargetFrameworkVersion: v12.0
Android NDK:
Android SDK: /Users/runner/Library/Android/sdk/
Android SDK Build Tools: /Users/runner/Library/Android/sdk/build-tools/30.0.2/
Java SDK: /Library/Java/JavaVirtualMachines/Temurin-Hotspot-11.jdk/Contents/Home/
Application Java class: android.app.Application
"/Users/runner/work/8/s/Mobile/CPSMobile/CPSMobile.Android/CPSMobile.Android.csproj" (PackageForAndroid target) (1) ->
(_BuildApkEmbed target) ->
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(1954,3): 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. [/Users/runner/work/8/s/Mobile/CPSMobile/CPSMobile.Android/CPSMobile.Android.csproj]
[Xamarin.Android.Tools.AndroidSdk] Permit NDK r25
jonathanpeppers commentedon Aug 4, 2022
I found something that prevents the selection of r25: dotnet/android-tools#190
Versions with Android NDK r24 or lower should work, though. As long as one of those is installed.
65 remaining items
GreatBarrier86 commentedon Sep 1, 2022
@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: #7233 (comment)
jonathanpeppers commentedon Sep 1, 2022
I don't think I use the
XamarinAndroid.yaml task, where did you see that? If someone is working on lately, it isn't the Xamarin.Android team, so I'm not sure about its status.Personally, I don't see what value it has over the regular MSBuild task. If there is some value, we should just put that logic in Xamarin.Android/.NET 6 instead?
GreatBarrier86 commentedon Sep 1, 2022
Unless i misunderstand, he's saying he saw that you do NOT use Xamarin.Android, but instead use MSBuild.
thomasphillipsgb commentedon Sep 1, 2022
Yes, that's correct. Sorry for the confusion; XamarinAndroid task- I've stopped using, MSBuild task - I've now switched over to use :D
salgiza commentedon Sep 2, 2022
Could someone post an example of how the MSBuild task should be configured to get the same result as this basic XamarinAndroid task?
We are having the same problem and I don't really mind using one or the other as long as it works, but all the docs for Azure DevOps use the XamarinAndroid task, and I'm totally unfamiliar with the MSBuild task 😢
thomasphillipsgb commentedon Sep 2, 2022
@salgiza sure! Although, see my response here #7233 (comment) 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;
salgiza commentedon Sep 5, 2022
Thanks a lot @Maxgamerboy1 , with all the messages in the thread, I had missed the one that said that changing the vmImage from macos-latest to macos-12 should fix the problem. Seeing the comments from @jonathanpeppers, though, I decided to do both (change the vmImage, and migrate from the XamarinAndroid task to MSBuild), and our pipeline is working again!
jonathanpeppers commentedon Sep 6, 2022
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!
GreatBarrier86 commentedon Sep 7, 2022
@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.thomasphillipsgb commentedon Sep 7, 2022
Ah, sorry, didn't know you were doing signing in a separate step. Yes, you'll need to use the
PackageForAndroidtarget in that case.GreatBarrier86 commentedon Sep 7, 2022
I certainly don't have to sign in a different step. Does the msbuild task also zipalign? If so, i don't see why i can't use the msbuild task for both.
thomasphillipsgb commentedon Sep 7, 2022
If using the
/t:SignAndroidPackageit should zipalign, then keysign for you, here's a snippet from one of my old builds showing the _Sign step;you'll also note prior to this step, MSBuild creates a debug keystore under the
_CreateAndroidDebugSigningKeystep.essentially, if you wanna zipalign and sign using your own keys, use
/t:PackageForAndroid, else let the/t:SignAndroidPackagedo it for youGreatBarrier86 commentedon Sep 8, 2022
@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/