locked
Using Android Native Development Kit on VSTS hosted agent RRS feed

  • Question

  • I'm trying to automate a build that includes a number of C++ libraries. I believe these require the Android Native Development Kit (NDK). The NDK should be available on the VSTS hosted agents according to (I can't post links...) a Google search for "visual studio hosted software" ( visualstudio.com agents/hosted#software)

    The hosted agents have installed:

    • Android Native Development Kit r13b


    However, my builds are failing:

    2017-04-05T14:47:03.2142985Z _BuildSdkCache:
    2017-04-05T14:47:03.2142985Z   sdk   Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidSdkDirectory not found.
    2017-04-05T14:47:03.2142985Z   sdk   Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidNdkDirectory not found.
    2017-04-05T14:47:03.2172902Z   sdk Looking for Android SDK..
    2017-04-05T14:47:03.2172902Z   sdk   Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidSdkDirectory not found.
    2017-04-05T14:47:03.2192902Z   sdk   Key HKLM\SOFTWARE\Novell\Mono for Android\AndroidSdkDirectory found:
    2017-04-05T14:47:03.2192902Z       Path does not contain adb in \platform-tools (C:\android-sdk-windows).
    2017-04-05T14:47:03.2192902Z   sdk   Key HKCU\SOFTWARE\Xamarin\MonoAndroid\PrivateAndroidSdkPath not found.
    2017-04-05T14:47:03.2192902Z   sdk   Key HKCU\SOFTWARE\Android SDK Tools\Path not found.
    2017-04-05T14:47:03.2822987Z   sdk   Key HKLM\SOFTWARE\Android SDK Tools\Path found:
    2017-04-05T14:47:03.2822987Z       Path contains adb in \platform-tools (C:\java\androidsdk\android-sdk).
    2017-04-05T14:47:03.3373129Z   sdk Looking for Android NDK..
    2017-04-05T14:47:03.3373129Z   sdk   Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidNdkDirectory not found.
    2017-04-05T14:47:03.3373129Z   sdk   Key HKLM\SOFTWARE\Novell\Mono for Android\AndroidNdkDirectory not found.
    2017-04-05T14:47:03.4572722Z    Found Android SDK. API levels: 10, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25
    2017-04-05T14:47:03.4866256Z _SetLatestTargetFrameworkVersion:
    2017-04-05T14:47:03.4866256Z   sdk Looking for Android NDK..
    2017-04-05T14:47:03.4866256Z   sdk   Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidNdkDirectory not found.
    2017-04-05T14:47:03.4866256Z   sdk   Key HKLM\SOFTWARE\Novell\Mono for Android\AndroidNdkDirectory not found.
    2017-04-05T14:47:03.4876284Z    Found Android SDK. API levels: 10, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25

    ... 

    2017-04-05T14:47:31.7469832Z _ResolveMonoAndroidSdks:
    2017-04-05T14:47:31.7469832Z   MonoAndroid Tools: C:\Program Files (x86)\MSBuild\Xamarin\Android\
    2017-04-05T14:47:31.7469832Z   MonoAndroid Binaries: C:\Program Files (x86)\MSBuild\Xamarin\Android\
    2017-04-05T14:47:31.7469832Z   Android Platform API level: 22
    2017-04-05T14:47:31.7469832Z   TargetFrameworkVersion: v5.1
    2017-04-05T14:47:31.7469832Z   Android NDK: \
    2017-04-05T14:47:31.7469832Z   Android SDK: C:\java\androidsdk\android-sdk\
    2017-04-05T14:47:31.7469832Z   Android SDK Build Tools: C:\java\androidsdk\android-sdk\build-tools\23.0.3\
    2017-04-05T14:47:31.7479716Z   Java SDK: C:\Program Files (x86)\Java\jdk1.7.0_75\

    ...

    2017-04-05T14:48:11.8600800Z ##[error]C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2227,3): Error XA5101: Missing Android NDK toolchains directory '\toolchains'. Please install the Android NDK.
    2017-04-05T14:48:11.8600800Z C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2227,3): error XA5101: Missing Android NDK toolchains directory '\toolchains'. Please install the Android NDK. [C:\a\1\s\***\***.csproj]
    2017-04-05T14:48:11.8600800Z Done Building Project "C:\a\1\s\***\***.csproj" (PackageForAndroid target(s)) -- FAILED.


    I don't know if the NDK is referenced somewhere in the csproj files? To my knowledge it is only declared within Visual Studio:

    Visual Studio -> Tools -> Options -> Xamarin

    Although checking the registry key mentioned above "Key HKCU\SOFTWARE\Novell\Mono for Android\AndroidNdkDirectory" I do have an entry on my local machine:

    "C:\ProgramData\Microsoft\AndroidNDK\android-ndk-r10e\"

    So it seems to me that the NDK is not installed on the hosted agent I am using.

    Is there a build step within VSTS to:

    * Confirm that the NDK is installed on the machine

    * Install the NDK if it is not installed?

    Thanks.

    Wednesday, April 5, 2017 3:40 PM

All replies

  • I would suggest you try the following workaround

    In the build definition, “Variables” tab set the below 2 variables and re-run your build. Share build logs after setting this workaround.

    ANDROID_NDK_HOME to C:\java\androidsdk\android-ndk-r13b
    ANDROID_NDK_PATH to C:\java\androidsdk\android-ndk-r13b

    Friday, April 7, 2017 10:52 AM
  • Thanks for the suggestion, it doesn't seem to have changed anything.

    I've added them like so (still can't add images):

    ANDROID_NDK_HOME C:\java\androidsdk\android-ndk-r13b 

    ANDROID_NDK_PATH C:\java\androidsdk\android-ndk-r13b

    I've also tried wrapping the path in quotes, but it fails with the same error:

    2017-04-07T11:23:25.2010338Z "C:\a\1\s\***\***.csproj" (PackageForAndroid target) (1) ->
    2017-04-07T11:23:25.2010338Z (_BuildApkEmbed target) -> 
    2017-04-07T11:23:25.2010338Z   C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2227,3): error XA5101: Missing Android NDK toolchains directory '\toolchains'. Please install the Android NDK. [C:\a\1\s\***\***.csproj]
    2017-04-07T11:23:25.2010338Z 
    2017-04-07T11:23:25.2010338Z     15 Warning(s)
    2017-04-07T11:23:25.2010338Z     1 Error(s)

    I can't see any reference to the path in the logs so it doesn't look like they were used. Do I need to reference those two variables anywhere or should they be used automatically? Change PATH or something?

    This site suggests something similar to what you've said, but it is specifically registering them as environment variables.

    http://www.developersite.org/102-59190-tfs

    Do I need to be doing something with the variables rather than just declaring them?


    Friday, April 7, 2017 1:22 PM
  • I am getting same issue using JDK 8 and MS Build Version- latest:  error XA5101: Missing Android NDK toolchains directory '\toolchains'. Please install the Android NDK.
    Thursday, April 20, 2017 3:31 PM
  • Both updates to the “Hosted” and “Hosted VS2017” pools have rolled out to all Scale Units.

    I would suggest you give a try again.

    Tuesday, April 25, 2017 4:25 AM
  • In Order to enable the NDK one has to set a Build Variable Named "AndroidNdkDirectory" and set its value to "C:\java\androidsdk\android-ndk-r13b".

    At least this works for me

    Monday, June 12, 2017 10:50 AM