game-ci / docker

Series of CI-specialised docker images for Unity.
https://hub.docker.com/u/unityci
MIT License
401 stars 125 forks source link

Burst Android NDK problem #180

Closed jjaine closed 11 months ago

jjaine commented 2 years ago

Bug description

I'm using the ubuntu-2021.3.2f1-android-1.0.1 image to build the project. However the build fails with the message

Burst requires the android NDK to be correctly installed (it can be installed via the unity installer add component) in order to build a standalone player for Android with ARMV7A_NEON32
The environment variable ANDROID_NDK_ROOT is undefined or empty, is the Android NDK correctly installed?

This problem arised when I updated from ubuntu-2020.3.30f1-android-0.15.0 to ubuntu-2021.3.2f1-android-1.0.1. If I disable Burst compilation for Android, then the build seems to work.

How to reproduce

Expected behavior

Additional details The packages I have installed are

Registered 54 packages:
  Packages from [https://packages.unity.com]:
    com.unity.ide.rider@3.0.13 (location: /playerconsole/Library/PackageCache/com.unity.ide.rider@3.0.13)
    com.unity.ide.visualstudio@2.0.14 (location: /playerconsole/Library/PackageCache/com.unity.ide.visualstudio@2.0.14)
    com.unity.ide.vscode@1.2.5 (location: /playerconsole/Library/PackageCache/com.unity.ide.vscode@1.2.5)
    com.unity.localization@1.0.5 (location: /playerconsole/Library/PackageCache/com.unity.localization@1.0.5)
    com.unity.mobile.android-logcat@1.2.3 (location: /playerconsole/Library/PackageCache/com.unity.mobile.android-logcat@1.2.3)
    com.unity.timeline@1.6.4 (location: /playerconsole/Library/PackageCache/com.unity.timeline@1.6.4)
    com.unity.mathematics@1.2.6 (location: /playerconsole/Library/PackageCache/com.unity.mathematics@1.2.6)
    com.unity.burst@1.6.5 (location: /playerconsole/Library/PackageCache/com.unity.burst@1.6.5)
    com.unity.addressables@1.19.19 (location: /playerconsole/Library/PackageCache/com.unity.addressables@1.19.19)
    com.unity.nuget.newtonsoft-json@3.0.2 (location: /playerconsole/Library/PackageCache/com.unity.nuget.newtonsoft-json@3.0.2)
    com.unity.test-framework@1.1.31 (location: /playerconsole/Library/PackageCache/com.unity.test-framework@1.1.31)
    com.unity.ext.nunit@1.0.6 (location: /playerconsole/Library/PackageCache/com.unity.ext.nunit@1.0.6)
    com.unity.searcher@4.9.1 (location: /playerconsole/Library/PackageCache/com.unity.searcher@4.9.1)
    com.unity.scriptablebuildpipeline@1.19.6 (location: /playerconsole/Library/PackageCache/com.unity.scriptablebuildpipeline@1.19.6)
  Built-in packages:
    com.unity.2d.sprite@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.2d.sprite@1.0.0)
    com.unity.render-pipelines.universal@12.1.6 (location: /playerconsole/Library/PackageCache/com.unity.render-pipelines.universal@12.1.6)
    com.unity.ui@2.0.0 (location: /playerconsole/Library/PackageCache/com.unity.ui@2.0.0)
    com.unity.ui.builder@2.0.0 (location: /playerconsole/Library/PackageCache/com.unity.ui.builder@2.0.0)
    com.unity.modules.ai@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.ai@1.0.0)
    com.unity.modules.androidjni@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.androidjni@1.0.0)
    com.unity.modules.animation@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.animation@1.0.0)
    com.unity.modules.assetbundle@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.assetbundle@1.0.0)
    com.unity.modules.audio@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.audio@1.0.0)
    com.unity.modules.cloth@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.cloth@1.0.0)
    com.unity.modules.director@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.director@1.0.0)
    com.unity.modules.imageconversion@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.imageconversion@1.0.0)
    com.unity.modules.imgui@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.imgui@1.0.0)
    com.unity.modules.jsonserialize@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.jsonserialize@1.0.0)
    com.unity.modules.particlesystem@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.particlesystem@1.0.0)
    com.unity.modules.physics@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.physics@1.0.0)
    com.unity.modules.physics2d@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.physics2d@1.0.0)
    com.unity.modules.screencapture@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.screencapture@1.0.0)
    com.unity.modules.terrain@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.terrain@1.0.0)
    com.unity.modules.terrainphysics@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.terrainphysics@1.0.0)
    com.unity.modules.tilemap@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.tilemap@1.0.0)
    com.unity.modules.ui@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.ui@1.0.0)
    com.unity.modules.uielements@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.uielements@1.0.0)
    com.unity.modules.umbra@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.umbra@1.0.0)
    com.unity.modules.unityanalytics@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.unityanalytics@1.0.0)
    com.unity.modules.unitywebrequest@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.unitywebrequest@1.0.0)
    com.unity.modules.unitywebrequestassetbundle@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.unitywebrequestassetbundle@1.0.0)
    com.unity.modules.unitywebrequestaudio@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.unitywebrequestaudio@1.0.0)
    com.unity.modules.unitywebrequesttexture@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.unitywebrequesttexture@1.0.0)
    com.unity.modules.unitywebrequestwww@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.unitywebrequestwww@1.0.0)
    com.unity.modules.vehicles@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.vehicles@1.0.0)
    com.unity.modules.video@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.video@1.0.0)
    com.unity.modules.vr@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.vr@1.0.0)
    com.unity.modules.wind@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.wind@1.0.0)
    com.unity.modules.xr@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.xr@1.0.0)
    com.unity.modules.subsystems@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.subsystems@1.0.0)
    com.unity.modules.uielementsnative@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.modules.uielementsnative@1.0.0)
    com.unity.render-pipelines.core@12.1.6 (location: /playerconsole/Library/PackageCache/com.unity.render-pipelines.core@12.1.6)
    com.unity.shadergraph@12.1.6 (location: /playerconsole/Library/PackageCache/com.unity.shadergraph@12.1.6)
    com.unity.ugui@1.0.0 (location: /playerconsole/Library/PackageCache/com.unity.ugui@1.0.0)
r4ravi2008 commented 1 year ago

Facing the same issue when running this command for first time in fresh install of project:

unity-editor \
    -batchmode \
    -nographics \
    -logFile  \
    -quit \
    -projectPath <path> \
    -executeMethod <buildscriptInvoke>

Rerunning the command again fixes it.

JakobAnarkyLabs commented 1 year ago

I had the same issue but was able to get around it by applying some EditorPrefs settings in my build script:

EditorPrefs.SetBool("JdkUseEmbedded", true);
EditorPrefs.SetBool("NdkUseEmbedded", true);
EditorPrefs.SetBool("SdkUseEmbedded", true);
EditorPrefs.SetBool("GradleUseEmbedded", true);
EditorPrefs.SetBool("AndroidGradleStopDaemonsOnExit", true);

(all of these are probably not related with the current issue - but at least "NdkUseEmbedded")

netlander commented 1 year ago

@JakobAnarkyLabs thanks for saving me from tearing out the last few hair strands I have left.

lordaku commented 1 year ago

Hi @JakobAnarkyLabs I was checking the official documentation of Unity related with Burst. And I've read the next:

If compiling for a non desktop platform, or you have disabled cross compilation support, then Burst compilation requires specific platform compilation tools (similar to IL2CPP), the below table can be used to determine the current level of support for AOT compilation. Screenshot 2023-05-12 at 11 59 54

If a host/target combination is not listed, it is at present not supported for Burst compilation. If a target is not valid (missing tools/unsupported), Burst compilation will not be used (may fail), but the target will still be built without Burst optimisations.

So my question is: How are you be able to compile Burst (linux + android)? According with that table that combination is not possible.

The unity documentation can be found here: https://docs.unity3d.com/Packages/com.unity.burst@1.6/manual/docs/StandalonePlayerSupport.html

Thanks!

JakobAnarkyLabs commented 1 year ago

Hi @lordaku

Yes, you are probably right about Burst (that it can't currently be compiled for Android on a Linux machine) - at least, that is what the documentation seems to suggest. I didn't notice that @jjaine was having this issue on a Linux machine - I just saw that the error message was the same as the one I got (on my Windows machine). So I guess that it is not really correct that I had the same issue as @jjaine (though maybe the same as @r4ravi2008 ...) but rather a related on Windows. Sorry about that.

AndrewKahr commented 11 months ago

Android images on windows are now released with v3 images! This should allow burst compilation