Skip to content

Xamarin.Android project not building when using NDK r-22 #5526

Closed
@lwschan

Description

@lwschan

Recently, some changes were made to the macOS image, updating the Android NDK bundle from r-21 to r-22. Ever since the update, many Xamarin.Android projects have had problems building.

Refer to https://developercommunity2.visualstudio.com/t/error-xa5101-platform-library-directory-for-target/1313156?from=email and actions/runner-images#2481 and actions/runner-images#2481

In the Microsoft Developer Community thread, a solution provided by one of the commetors is to install NDK r-21 manually, and use msbuildArguments in the Xamarin.Android build task to force it to choose the NDK installed. This step cannot work for App Center, because App Center does not allow us to pass in any argument for the build task.

Is there a way to force Xamarin.Android project to use the newest NDK version installed? Instead of trying to use an old one. We are not targetting any specific NDK version in our app, I also couldn't find a config to change it. So I am not sure why the build task is trying to use such an old version.

Tested using Xamarin.Android 11.1 and 10.3, same result.

Steps to Reproduce

  1. Create a Xamarin.Android project
  2. Create a pipeline on Azure/App Center that builds the project
  3. Build using the pipeline

Expected Behavior

Build without error.

Actual Behavior

(_BuildApkEmbed target) -> 
  /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2099,3): error : error XA5101: Platform library directory for target Arm and API Level 4 was not found. Expected path is "/Users/runner/Library/Android/sdk/ndk-bundle/platforms/android-4/arch-arm/usr/lib" [/Users/runner/work/1/s/MobileApp/MobileApp.Droid/MobileApp.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2099,3): error :   at Java.Interop.Tools.Diagnostics.Diagnostic.Error (System.Int32 code, System.String message, System.Object[] args) [0x00008] in <a01ded9e489d49e3902da78cd983b642>:0  [/Users/runner/work/1/s/MobileApp/MobileApp.Droid/MobileApp.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2099,3): error :   at Xamarin.Android.Tasks.Aot+<GetAotConfigs>d__80.MoveNext () [0x00393] in <3e53085892e04b628169d0ea2d9ff8b6>:0  [/Users/runner/work/1/s/MobileApp/MobileApp.Droid/MobileApp.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2099,3): error :   at Xamarin.Android.Tasks.AsyncTaskExtensions.WhenAllWithLock[TSource] (Xamarin.Build.AsyncTask asyncTask, System.Collections.Generic.IEnumerable`1[T] source, System.Action`2[T1,T2] body) [0x0006e] in <3e53085892e04b628169d0ea2d9ff8b6>:0  [/Users/runner/work/1/s/MobileApp/MobileApp.Droid/MobileApp.Droid.csproj]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2099,3): error :   at Xamarin.Android.Tasks.Aot.RunTaskAsync () [0x000a9] in <3e53085892e04b628169d0ea2d9ff8b6>:0  [/Users/runner/work/1/s/MobileApp/MobileApp.Droid/MobileApp.Droid.csproj]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: App+Library BuildIssues when building Library projects or Application projects.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions