CesiumGS / cesium-unity

Bringing the 3D geospatial ecosystem to Unity
https://cesium.com/platform/cesium-for-unity/
Apache License 2.0
347 stars 83 forks source link

Android build broken on v1.9.0 #456

Closed j9liu closed 4 months ago

j9liu commented 5 months ago

Reported on the forum here.

User experiencing problems building for Android with the following circumstances:

Reportedly, this doesn't happen with v1.8.0. They've shared this callstack with us:

An error occurred while building CesiumForUnityNative. See E:\UnityProject\cesium-unity-samples-1.9.0\Packages\com.cesium.unity\native~\build-Android-arm64\build.log for details. The command-line was: cmake --build “E:\UnityProject\cesium-unity-samples-1.9.0\Packages\com.cesium.unity\native~\build-Android-arm64” --config Debug --parallel 21 --target install UnityEngine.Debug:LogError (object) CesiumForUnity.CompileCesiumForUnityNative:RunAndLog (System.Diagnostics.ProcessStartInfo,System.IO.StreamWriter,string) (at ./Packages/com.cesium.unity/Editor/CompileCesiumForUnityNative.cs:512) CesiumForUnity.CompileCesiumForUnityNative:BuildNativeLibrary (CesiumForUnity.CompileCesiumForUnityNative/LibraryToBuild) (at ./Packages/com.cesium.unity/Editor/CompileCesiumForUnityNative.cs:478) CesiumForUnity.CompileCesiumForUnityNative:OnPostBuildPlayerScriptDLLs (UnityEditor.Build.Reporting.BuildReport) (at ./Packages/com.cesium.unity/Editor/CompileCesiumForUnityNative.cs:210) UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

CommandInvokationFailure: Gradle build failed. C:\Program Files\Unity\Hub\Editor\2023.2.17f1c1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\bin\java.exe -classpath “C:\Program Files\Unity\Hub\Editor\2023.2.17f1c1\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-7.6.jar” org.gradle.launcher.GradleMain “-Dorg.gradle.jvmargs=-Xmx4096m” “assembleDebug”

kring commented 5 months ago

To diagnose this, we need to see the log file mentioned in the error message.

j9liu commented 5 months ago

Yep. I asked the user for more information before opening the issue. (Just wanted to do so before I forgot.)

They posted the full log here. It looks like this is the offending error:

make[2]: *** No rule to make target ‘extern/cesium-native/extern/draco/CMakeFiles/draco_compression_attributes_pred_schemes_enc.dir/4903a2f1d67bacb7cbad22462a10a95f/prediction_scheme_encoder_factory.cc.o’, needed by ‘extern/cesium-native/extern/draco/libdracod.a’. Stop.

I remember that mid-March, we updated the Draco library in https://github.com/CesiumGS/cesium-native/pull/829. This was probably incorporated into the April Cesium for Unity release.

kring commented 5 months ago

Notice that same file is mentioned earlier in the log:

CMake Warning in extern/cesium-native/extern/draco/CMakeLists.txt:
The object file directory

E:/UnityProject/cesium-unity-samples-1.9.0/Packages/com.cesium.unity/native~/build-Android-arm64/extern/cesium-native/extern/draco/CMakeFiles/draco_compression_attributes_pred_schemes_enc.dir/
has 192 characters. The maximum full path to an object file is 250
characters (see CMAKE_OBJECT_PATH_MAX). Object file

4903a2f1d67bacb7cbad22462a10a95f/prediction_scheme_encoder_factory.cc.o
cannot be safely placed under this directory. The build may not work
correctly.

It's possible this user doesn't have long paths enabled. This is mentioned as a requirement in the prerequisites section of the developer setup instructions: https://github.com/CesiumGS/cesium-unity/blob/main/Documentation~/developer-setup.md

It's also possible that long paths are enabled, but the path is too long anyway (even when Windows has no path limit, some tools do). Moving the project to E:\a or similar is a good way to exclude that possibility.

j9liu commented 4 months ago

Turned out it was the long paths issue, thanks @kring !