Hi all,
I understand Cesium for Unity does not consider Linux a supported platform, but I am trying to incorporate this dependency into our existing CI process which is based off Linux (Ubuntu). From reading the docs and forums it sounds like building from source on Linux should be possible, and after a few days of poking at this, I have it building successfully, but running into an issue when packaging into my project and building an apk.
I took a read through this thread, which was helpful:
I am doing something similar, where I install all the dependencies in a docker - cmake 3.27.1, .NET V7, and I’m running a headless Unity 2022.3.4f1 to compile. I build reinterop and then run CesiumForUnity.BuildCesiumForUnity.CompileForEditorAndExit
using the sample projects repo, that produces the .so files and everything seems to be fine. That’s the last step of my docker, then I copy over the entire com.cesium.unity
folder from the sample project’s Packages into my project’s Packages folder, then I run my build.
The build is “successful” but the resulting apk throws an error when I run it on the device (Quest Pro):
NotImplementedException: The native implementation is missing so Update cannot be invoked. This may be caused by a missing call to CreateImplementation in one of your constructors, or it may be that the entire native implementation shared library is missing or out of date.
I also noticed these errors in my build logs (when I build the Android app)
Fallback handler could not load library /opt/unity/Editor/Data/MonoBleedingEdge/lib/libCesiumForUnityNative-Runtime.so
Fallback handler could not load library /opt/unity/Editor/Data/MonoBleedingEdge/lib/libCesiumForUnityNative-Runtime
Fallback handler could not load library /opt/unity/Editor/Data/MonoBleedingEdge/lib/libCesiumForUnityNative-Runtime
DllNotFoundException: CesiumForUnityNative-Runtime assembly:<unknown assembly> type:<unknown type> member:(null)
at (wrapper managed-to-native) Reinterop.ReinteropInitializer.initializeReinterop(ulong,intptr,int)
at Reinterop.ReinteropInitializer..cctor () [0x03d0e] in ./Reinterop/Reinterop.RoslynSourceGenerator/ReinteropInitializer.cs:947
Rethrow as TypeInitializationException: The type initializer for 'Reinterop.ReinteropInitializer' threw an exception.
at CesiumForUnity.CesiumGeoreference.CreateImplementation () [0x00000] in ./Reinterop/Reinterop.RoslynSourceGenerator/CesiumGeoreference-generated.cs:35
at CesiumForUnity.CesiumGeoreference..ctor () [0x00072] in ./Reinterop/Reinterop.RoslynSourceGenerator/CesiumGeoreference-generated.cs:52
...
...
...
Win32Exception: ApplicationName='cmake', CommandLine='-B /root/project/Packages/com.cesium.unity/native~/build-Android-arm64 -S /root/project/Packages/com.cesium.unity/native~ -DEDITOR=false -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX="/root/project/Packages/com.cesium.unity/Plugins/Android/arm64" -DREINTEROP_GENERATED_DIRECTORY=generated-Android -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a -DCMAKE_TOOLCHAIN_FILE="extern/android-toolchain.cmake"', CurrentDirectory='/root/project/Packages/com.cesium.unity/native~', Native error= Cannot find the specified file
at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x002f9] in <d2ad639727fd46a8b6c982e3f40f3172>:0
at System.Diagnostics.Process.Start () [0x0003a] in <d2ad639727fd46a8b6c982e3f40f3172>:0
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
at CesiumForUnity.CompileCesiumForUnityNative.RunAndLog (System.Diagnostics.ProcessStartInfo startInfo, System.IO.StreamWriter log, System.String logFilename) [0x0003e] in ./Packages/com.cesium.unity/Editor/CompileCesiumForUnityNative.cs:463
at CesiumForUnity.CompileCesiumForUnityNative.BuildNativeLibrary (CesiumForUnity.CompileCesiumForUnityNative+LibraryToBuild library) [0x001cd] in ./Packages/com.cesium.unity/Editor/CompileCesiumForUnityNative.cs:421
at CesiumForUnity.CompileCesiumForUnityNative.OnPostBuildPlayerScriptDLLs (UnityEditor.Build.Reporting.BuildReport report) [0x00016] in ./Packages/com.cesium.unity/Editor/CompileCesiumForUnityNative.cs:195
at UnityEditor.Build.BuildPipelineInterfaces.OnPostBuildPlayerScriptDLLs (UnityEditor.Build.Reporting.BuildReport report) [0x00033] in /home/bokken/build/output/unity/unity/Editor/Mono/BuildPipeline/BuildPipelineInterfaces.cs:603
One other thing I’ve tried is running CesiumForUnity.BuildCesiumForUnity.CompileForAndroidAndExit
at the end of my docker process, before moving over the package. This command is successful (I have to create the Empty Unity scene which I saw was done here https://github.com/CesiumGS/cesium-unity/blob/main/Build~/Package.cs#L49) and in my apk I have a larger libCesiumForUnityNative-Runtime.so
file which size is at least much closer to when I build locally, but still throws the same errors at runtime.
Would love any pointers!
Thanks!