Search Unity

Specifying NDK Location on a headless buildserver

Discussion in 'Editor & General Support' started by diekeure, Dec 5, 2016.

  1. diekeure

    diekeure

    Joined:
    Jan 25, 2013
    Posts:
    221
    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
     
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    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:
    Code (CSharp):
    1.  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.
     
    diekeure likes this.
  3. diekeure

    diekeure

    Joined:
    Jan 25, 2013
    Posts:
    221
    Right, thanks for the tip, it led me to a solution. I wrote this script and put it in an empty project called "SetNDKPath":

    Code (csharp):
    1.  
    2. using UnityEditor;
    3. using UnityEngine;
    4.  
    5. public class SetPaths : MonoBehaviour
    6. {
    7.    public static void SetNDKPath()
    8.    {
    9.      EditorPrefs.SetString("AndroidNdkRoot", @"E:\sdks\android-ndk-r10e");
    10.      Debug.LogFormat("Android NDK Path is now {0}", EditorPrefs.GetString("AndroidNdkRoot"));
    11.    }  
    12. }
    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.
     
    liortal likes this.
  4. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    story of our lives, isn't it ? :)