Unable to locate Android NDK when building from command line


I’m building Android from Unity on my CI machine and can’t solve the issue with missing NDK. There is NDK r16 and Unity 2019.1.1 installed, but when build is run in the batchmode I get - Unable to locate Android NDK.

Everything worked fine until I switched to support 64-bit architectures (Google requirement since 1 Aug 2019).

Here’s my command:

/Applications/Unity/Unity.app/Contents/MacOS/Unity \

-nographics \

-quit \

-batchmode \

-executeMethod UnityCommandLine.Build \

-androidSdkPath “$ANDROID_HOME” \

-androidNdkPath “$ANDROID_NDK_HOME” \

-buildOutput $DEPLOY_DIR/app.apk \

-buildPlatform android \

-androidKeystorePath $SOURCE_DIR/App_Keystore \

-androidKeystorePassword $ANDROID_KEYSTORE_PASSWORD \

-androidKeystoreAlias $ANDROID_KEYSTORE_ALIAS \

-androidKeystoreAliasPassword $ANDROID_KEYSTORE_ALIAS_PASSWORD \

-logFile /dev/stdout \

-productName “$APPLICATION_NAME”

Have any idea what can I do with this? I’ve tried different NDK versions/locations, setting NDK path directly (as you can see in my command) but none of these work.


well… I’ve found the answer…quite unexpected…

It turns out that you have to use two different keys in Editor to make it work:

EditorPrefs.SetString("AndroidNdkRootR16b", "Your__Path");
EditorPrefs.SetString("AndroidNdkRoot", "Your__Path");

I’ve found part of the anwser here: https://forum.unity.com/threads/android-ndk-path-editorprefs-key-changed.639103/, but it’s only half right. Both were needed in my case.

Best regards,