Search Unity

Burst compilation error: Android NDK path problem

Discussion in 'Burst' started by any_user, Mar 27, 2019.

  1. any_user

    any_user

    Joined:
    Oct 19, 2008
    Posts:
    374
    I had a problem with Android builds failing because the NDK was not found (ANDROID_NDK_HOME not set). I did set the NDK path in the editor preferences, but it still didn't work.

    It turned to be a problem with the editor preferences, where setting the NDK path through the Project settings UI sets the "AndroidNdkRootR16b" property instead of the (previously used?) "AndroidNdkRoot" property. Burst instead seems to rely on "AndroidNdkRoot" being set.

    Here's a small helper script that solved the problem for me, in case somebody runs into the same problem:

    Code (CSharp):
    1. using System;
    2. using UnityEditor;
    3. using UnityEditor.Build;
    4. using UnityEditor.Build.Reporting;
    5.  
    6. public class SetAndroidNdkBeforeBuild : IPreprocessBuildWithReport
    7. {
    8.     public int callbackOrder { get; }
    9.     public void OnPreprocessBuild(BuildReport report)
    10.     {
    11.         if (report.summary.platform == BuildTarget.Android)
    12.         {
    13.             var ndkHome = EditorPrefs.GetString("AndroidNdkRootR16b");
    14.             EditorPrefs.SetString("AndroidNdkRoot",ndkHome);
    15.         }
    16.     }
    17. }
    Probably that should be fixed in the burst build pipeline.
     
    tcjkant likes this.
  2. NoDumbQuestion

    NoDumbQuestion

    Joined:
    Nov 10, 2017
    Posts:
    186
    It only Editor bugs. Someone forgot to use
    AndroidNdkRootR16b 
    instead of
    AndroidNdkRoot
    when building with Burst and not normal Android. You can also fix this one time with registry editor
     
  3. any_user

    any_user

    Joined:
    Oct 19, 2008
    Posts:
    374
    On windows, the one-time registry fix worked for me, but it didn‘t work on mac when i tried. I definitely prefer autoconfiguration over messing around with registry entries on each computer opening the project.