DevOps Xamarin Android Build Task fails with Bundle Assemblies Into Native Code enabled

Thomas 131 Reputation points
2021-01-19T14:13:21.093+00:00

Hello!
We have been using Xamarin Forms to make UWP, iOS and Android apps and make use of DevOps build agents to build, unit test, sign and deploy our apps. There was a recent image update for both the Windows and macOS images (prev. 20201212.1 curr. 20210110.1). The new image is erroring in the Xamarin Android build step at the _BuildApkEmbed stage, with the following error:

MacOS Image
_BuildApkEmbed:
[mkbundle stderr]
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2135,3): error : Android include path not found. Tried: /Users/runner/Library/Android/sdk/ndk-bundle/sysroot/usr/include [/Users/runner/work/1/s/.....Android.csproj]
Done Building Project "/Users/runner/work/1/s/.....Android.csproj" (PackageForAndroid target(s)) -- FAILED.

Windows Image
[mkbundle stderr]
[error]C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2135,3): Error : Android include path not found. Tried: C:\Program Files (x86)\Android\android-sdk\ndk-bundle\sysroot\usr\include
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2135,3): error : Android include path not found. Tried: C:\Program Files (x86)\Android\android-sdk\ndk-bundle\sysroot\usr\include [D:\a\1\s......Android.csproj]
Done Building Project "D:\a\1\s......Android.csproj" (PackageForAndroid target(s)) -- FAILED.

If you see, there is this "sysroot/..." path appended to the NDK path. I'm not sure where this is coming from or how to get around this. As mentioned, it errors in both the Windows and MacOS images.
Windows2019-Readme.md
macos-10.15-Readme.md

This error only occurs if the BundleAssemblies property in the .csproj is set to true. I'm not sure if we have missed an update on how to consume the NDK correctly as i cant find any documentation (or similar errors/discussions) pertaining to this. We have tried setting the /p:AndroidNDKDirectory=$(ANDROID_NDK_PATH), which still doesn't remedy the issue.

Any help or advice would be much appreciated!
Thanks, Thomas

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,301 questions
0 comments No comments
{count} votes

Accepted answer
  1. Thomas 131 Reputation points
    2021-01-19T15:47:41.163+00:00

    I'm not sure how I missed this, but it seems to be a reported issue over on the Xamarin Android repository 5499
    At the time of writing, the recommendation it to update your step to consume a previous version of the NDK

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful