Specifying NDK Location on a headless buildserver

Hello,

Small question, we have a buildserver that must run unity in batch mode (no graphics card, so the editor interface cannot run). We have an Android project where we want to use il2cpp, but on that buildserver we get the error

“Error when building for platform Android: UnityException: Unable to detect NDK version, please pick a different folder.”

Obviously, because I haven’t set the folder. The documentation and other forum posts only refer to settings that folder via the editor interface. Is there a way to set this path without the editor interface?

Thank you,
Alex

You can always use Reflector, MonoDevelop or any other tool that lets you “peek” into compiled assemblies to find out how the editor stores this information.

For the NDK path, this is how it’s retrieved:

 this.m_AndroidNdkPath = EditorPrefs.GetString("AndroidNdkRoot");

You can try to do the same & assign this property to the actual path where you have the NDK installed (note that it has to be the exact version they’re looking for.

1 Like

Right, thanks for the tip, it led me to a solution. I wrote this script and put it in an empty project called “SetNDKPath”:

using UnityEditor;
using UnityEngine;

public class SetPaths : MonoBehaviour
{
   public static void SetNDKPath()
   {
     EditorPrefs.SetString("AndroidNdkRoot", @"E:\sdks\android-ndk-r10e");
     Debug.LogFormat("Android NDK Path is now {0}", EditorPrefs.GetString("AndroidNdkRoot"));
   }  
}

And then ran this command:

call “C:\Program Files\Unity 5.4\Editor\Unity.exe” -quit -batchmode -projectPath “C:\Develop\SetNDKPath” -logFile ndk.log -executeMethod SetPaths.SetNDKPath

Resulting in the ndk.log containing “Android NDK Path is now E:/sdks/android-ndk-r10e/”

Cumbersome, but it did the trick. Thank you.

1 Like

story of our lives, isn’t it ? :slight_smile: