Build failed on Windows for Android apk

Hello there,I try build Android apk on Windows.But I got failed from Ninja.There is the error info:

[260/267] Linking CXX static library C:\Users\white\BabylonNative\build\Android_arm64-v8a\Polyfills\Canvas\libCanvas.a  FAILED: C:/Users/white/BabylonNative/build/Android_arm64-v8a/Polyfills/Canvas/libCanvas.a
  cmd.exe /C "cd . && C:\Users\white\AppData\Local\Android\Sdk\cmake\3.22.1\bin\cmake.exe -E rm -f C:\Users\white\BabylonNative\build\Android_arm64-v8a\Polyfills\Canvas\libCanvas.a && C:\Users\white\AppData\Local\Android\Sdk\ndk\21.4.7075529\toolchains\llvm\prebuilt\windows-x86_64\bin\aarch64-linux-android-ar.exe qc C:\Users\white\BabylonNative\build\Android_arm64-v8a\Polyfills\Canvas\libCanvas.a  ../../../../../../../../build/Android_arm64-v8a/Polyfills/Canvas/CMakeFiles/Canvas.dir/Source/Canvas.cpp.o ../../../../../../../../build/Android_arm64-v8a/Polyfills/Canvas/CMakeFiles/Canvas.dir/Source/Image.cpp.o ../../../../../../../../build/Android_arm64-v8a/Polyfills/Canvas/CMakeFiles/Canvas.dir/Source/ImageData.cpp.o ../../../../../../../../build/Android_arm64-v8a/Polyfills/Canvas/CMakeFiles/Canvas.dir/Source/Context.cpp.o ../../../../../../../../build/Android_arm64-v8a/Polyfills/Canvas/CMakeFiles/Canvas.dir/Source/MeasureText.cpp.o ../../../../../../../../build/Android_arm64-v8a/Polyfills/Canvas/CMakeFiles/Canvas.dir/Source/nanovg_babylon.cpp.o ../../../../../../../../build/Android_arm64-v8a/Polyfills/Canvas/CMakeFiles/Canvas.dir/C_/Users/white/BabylonNative/Dependencies/bgfx.cmake/bgfx/examples/common/font/font_manager.cpp.o ../../../../../../../../build/Android_arm64-v8a/Polyfills/Canvas/CMakeFiles/Canvas.dir/C_/Users/white/BabylonNative/Dependencies/bgfx.cmake/bgfx/examples/common/font/text_buffer_manager.cpp.o ../../../../../../../../build/Android_arm64-v8a/Polyfills/Canvas/CMakeFiles/Canvas.dir/C_/Users/white/BabylonNative/Dependencies/bgfx.cmake/bgfx/examples/common/font/text_metrics.cpp.o ../../../../../../../../build/Android_arm64-v8a/Polyfills/Canvas/CMakeFiles/Canvas.dir/C_/Users/white/BabylonNative/Dependencies/bgfx.cmake/bgfx/examples/common/font/utf8.cpp.o ../../../../../../../../build/Android_arm64-v8a/Polyfills/Canvas/CMakeFiles/Canvas.dir/C_/Users/white/BabylonNative/Dependencies/bgfx.cmake/bgfx/examples/common/cube_atlas.cpp.o ../../../../../../../../build/Android_arm64-v8a/Polyfills/Canvas/CMakeFiles/Canvas.dir/C_/Users/white/BabylonNative/Dependencies/bgfx.cmake/bgfx/examples/common/nanovg/nanovg.cpp.o && C:\Users\white\AppData\Local\Android\Sdk\ndk\21.4.7075529\toolchains\llvm\prebuilt\windows-x86_64\bin\aarch64-linux-android-ranlib.exe C:\Users\white\BabylonNative\build\Android_arm64-v8a\Polyfills\Canvas\libCanvas.a && cd ."
  C:\Users\white\AppData\Local\Android\Sdk\ndk\21.4.7075529\toolchains\llvm\prebuilt\windows-x86_64\bin\aarch64-linux-android-ar.exe: ../../../../../../../../build/Android_arm64-v8a/Polyfills/Canvas/CMakeFiles/Canvas.dir/C_/Users/white/BabylonNative/Dependencies/bgfx.cmake/bgfx/examples/common/font/font_manager.cpp.o: No such file or directory

ninja: build stopped: subcommand failed.

I see it say “/font/font_manager.cpp.o: No such file or directory”,but I found the font_manager.cpp.o in “build/Android_arm64-v8a” dir.

Can anyone help me?

Node Version: v16.14.0 (by NVM)
JDK Version: OpenJDK Runtime Environment Corretto-11.0.20.8.1 (build 11.0.20+8-LTS)
Ninja Version : 1.11.1

Hi @whitestar776 and welcome to the forum.
I got this issue with another .o and it was because of long paths support in Windows that was not enable.
I have a WIP branch that may fix this issue: Use fetch content instead of submodules by CedricGuillemet · Pull Request #1312 · BabylonJS/BabylonNative · GitHub
Try to build the branch and let me know how it goes.
LAst resort : can you please try to enable long path and if it still doesn’t work, can you try to clone is a shorter repository like c:\BN

Hi @Cedric ,thanks for your reply,I move it to short path,then build success.

But when I launch the app,I got a black screen,and the logcat like this:

2023-10-19 16:58:54.773 3831-3831 ApplicationLoaders com…roid.babylonnative.playground D Returning zygote-cached class loader: /system/framework/android.test.base.jar
2023-10-19 16:58:54.848 3831-3831 Perf com…roid.babylonnative.playground I Connecting to perf service.
2023-10-19 16:58:54.859 3831-3831 GraphicsEnvironment com…roid.babylonnative.playground V ANGLE Developer option for ‘com.android.babylonnative.playground’ set to: ‘default’
2023-10-19 16:58:54.860 3831-3831 GraphicsEnvironment com…roid.babylonnative.playground V ANGLE GameManagerService for com.android.babylonnative.playground: false
2023-10-19 16:58:54.861 3831-3831 GraphicsEnvironment com…roid.babylonnative.playground V App is not on the allowlist for updatable production driver.
2023-10-19 16:58:54.865 3831-3831 NetworkSecurityConfig com…roid.babylonnative.playground D No Network Security Config specified, using platform default
2023-10-19 16:58:54.866 3831-3831 NetworkSecurityConfig com…roid.babylonnative.playground D No Network Security Config specified, using platform default
2023-10-19 16:58:54.945 3831-3831 JavaScriptCore.Version com…roid.babylonnative.playground D 250230.2.1
2023-10-19 16:58:54.989 3831-3831 OpenGLRenderer com…roid.babylonnative.playground D get process name:com.android.babylonnative.playg pid:3831
2023-10-19 16:58:54.990 3831-3831 OpenGLRenderer com…roid.babylonnative.playground D After start JankHealer thread
2023-10-19 16:58:54.990 3831-3863 OpenGLRenderer com…roid.babylonnative.playground D healer thread begins
2023-10-19 16:58:54.990 3831-3831 OpenGLRenderer com…roid.babylonnative.playground E start vsync check timer failed:-1
2023-10-19 16:58:54.990 3831-3831 OpenGLRenderer com…roid.babylonnative.playground D check ys,get process name:com.android.babylonnative.playg pid:3831
2023-10-19 16:58:54.990 3831-3863 OpenGLRenderer com…roid.babylonnative.playground D enable it to run in smalle cores return:0
2023-10-19 16:58:54.990 3831-3863 OpenGLRenderer com…roid.babylonnative.playground D Begin to register handler for vsync fd
2023-10-19 16:58:54.990 3831-3863 OpenGLRenderer com…roid.babylonnative.playground D set flags for fd returns:0
2023-10-19 16:58:54.990 3831-3863 OpenGLRenderer com…roid.babylonnative.playground D Begin to register handler for state check fd
2023-10-19 16:58:54.990 3831-3863 OpenGLRenderer com…roid.babylonnative.playground D set flags for fd returns:0
2023-10-19 16:58:54.990 3831-3863 OpenGLRenderer com…roid.babylonnative.playground D Begin to register handler for fps check fd
2023-10-19 16:58:54.990 3831-3863 OpenGLRenderer com…roid.babylonnative.playground D set flags for fd returns:0
2023-10-19 16:58:54.990 3831-3863 OpenGLRenderer com…roid.babylonnative.playground D Begin to register handler for cpu check fd
2023-10-19 16:58:54.990 3831-3863 OpenGLRenderer com…roid.babylonnative.playground D set flags for fd returns:0
2023-10-19 16:58:54.990 3831-3863 OpenGLRenderer com…roid.babylonnative.playground D Begin to register handler for gpu check fd
2023-10-19 16:58:54.990 3831-3863 OpenGLRenderer com…roid.babylonnative.playground D set flags for fd returns:0
2023-10-19 16:58:54.990 3831-3863 OpenGLRenderer com…roid.babylonnative.playground D Enter healer thread loop
2023-10-19 16:58:55.023 3831-3859 AdrenoGLES-0 com…roid.babylonnative.playground I QUALCOMM build : 1159e70389, I1027f1d7d9
Build Date : 04/08/22
OpenGL ES Shader Compiler Version: EV031.32.02.17
Local Branch :
Remote Branch :
Remote Branch :
Reconstruct Branch :
2023-10-19 16:58:55.024 3831-3859 AdrenoGLES-0 com…roid.babylonnative.playground I Build Config : S P 10.0.7 AArch64
2023-10-19 16:58:55.024 3831-3859 AdrenoGLES-0 com…roid.babylonnative.playground I Driver Path : /vendor/lib64/egl/libGLESv2_adreno.so
2023-10-19 16:58:55.029 3831-3859 AdrenoGLES-0 com…roid.babylonnative.playground I PFP: 0x016ee197, ME: 0x00000000
2023-10-19 16:58:55.047 3831-3831 hw-ProcessState com…roid.babylonnative.playground D Binder ioctl to enable oneway spam detection failed: Invalid argument
2023-10-19 16:58:55.106 3831-3863 OpenGLRenderer com…roid.babylonnative.playground W !!!timeout for vsync dealing
2023-10-19 16:58:55.106 3831-3863 OpenGLRenderer com…roid.babylonnative.playground D switchState now,exit:0 enter:0
2023-10-19 16:58:55.106 3831-3863 OpenGLRenderer com…roid.babylonnative.playground D Idle state exit
2023-10-19 16:58:55.106 3831-3863 OpenGLRenderer com…roid.babylonnative.playground E initiateBoost boost params for CPU not initialized,use default config
2023-10-19 16:58:55.107 3831-3863 OpenGLRenderer com…roid.babylonnative.playground D startBoostV3 read result:-1
2023-10-19 16:58:55.107 3831-3863 OpenGLRenderer com…roid.babylonnative.playground E Fail to do boost for resource:1 error:-1
2023-10-19 16:58:55.107 3831-3863 OpenGLRenderer com…roid.babylonnative.playground D finish enter, updated state:0, target state:1 oldstate:0
2023-10-19 16:58:55.107 3831-3863 OpenGLRenderer com…roid.babylonnative.playground E Fail to enter state
2023-10-19 16:58:55.145 3831-3831 Choreographer com…roid.babylonnative.playground D Potential long vsync dealing latency:126670174
2023-10-19 16:58:55.145 3831-3831 OpenGLRenderer com…roid.babylonnative.playground D onVsyncDealingBegan,latency:126.670174, frame:41048551
2023-10-19 16:58:55.146 3831-3863 OpenGLRenderer com…roid.babylonnative.playground D switchState now,exit:0 enter:0
2023-10-19 16:58:55.146 3831-3863 OpenGLRenderer com…roid.babylonnative.playground D Idle state exit
2023-10-19 16:58:55.146 3831-3863 OpenGLRenderer com…roid.babylonnative.playground E initiateBoost boost params for CPU not initialized,use default config
2023-10-19 16:58:55.146 3831-3863 OpenGLRenderer com…roid.babylonnative.playground D startBoostV3 read result:-1
2023-10-19 16:58:55.146 3831-3863 OpenGLRenderer com…roid.babylonnative.playground E Fail to do boost for resource:1 error:-1
2023-10-19 16:58:55.146 3831-3863 OpenGLRenderer com…roid.babylonnative.playground D finish enter, updated state:0, target state:1 oldstate:0
2023-10-19 16:58:55.146 3831-3863 OpenGLRenderer com…roid.babylonnative.playground E Fail to enter state
2023-10-19 16:58:55.503 3831-3887 WindowManager com…roid.babylonnative.playground D checkIfDrawnByThreadedRenderer enter
2023-10-19 16:58:55.503 3831-3887 WindowManager com…roid.babylonnative.playground D checkIfDrawnByThreadedRenderer render enabled:true
2023-10-19 16:58:55.504 3831-3887 OpenGLRenderer com…roid.babylonnative.playground D startMonitorJank check size:23
2023-10-19 16:58:55.504 3831-3887 OpenGLRenderer com…roid.babylonnative.playground D valid count:22
2023-10-19 16:58:55.504 3831-3887 OpenGLRenderer com…roid.babylonnative.playground D Most frames are valid, assume it is drawn via renderthread
2023-10-19 16:58:55.504 3831-3887 Choreographer com…roid.babylonnative.playground D checkIfDrawnByThreadedRenderer return:Yes
2023-10-19 16:58:55.575 3831-3865 BabylonNative com…roid.babylonnative.playground E Uncaught Error: Can’t find variable: BABYLON

Am I missing any steps?

This is concerning. Can you see babylon.max.js file inside the .apk? are you building debug or release? Did you change the experience.js script or did you change the list of loaded scripts?

1 Like

I can see babylon.max.js in my .apk file,bot in release and debug .apk file,I just see these .so libs and .js file. But I’m sure I haven’t made any changes to the project configuration:

├── assets

│ └── Scripts

│ ├── ammo.js

│ ├── experience.js

│ ├── meshwriter.min.js

│ ├── playground_runner.js

│ ├── recast.js

│ └── validation_native.js

├── classes.dex

├── lib

│ └── arm64-v8a

│ ├── libarcore_sdk_c.so

│ ├── libarcore_sdk_jni.so

│ ├── libBabylonNativeJNI.so

│ ├── libc++_shared.so

│ ├── libjsc.so

│ └── liblog.so

I see in build.gradle have these code:

copy
{
    from '../../../node_modules/babylonjs'
    include "babylon.max.js"
    into 'src/main/assets/Scripts'
}
copy
{
    from '../../../node_modules/babylonjs-loaders'
    include "babylonjs.loaders.js"
    into 'src/main/assets/Scripts'
}

But seems it not works for me,I check the node_modules folder but it is not exist.

Maybe I should copy my own front page project to there?

I’m sorry, I’m an Android developer and I’m not very familiar with web frontends tech.

Indeed, it looks like something is going wrong. I’m taking a look.

1 Like

I have a PR

Let me know @whitestar776 if this works for you (it should :slight_smile: )

This PR works, but I have to compile it twice. When I first compiled, there were still no babylon.max.js and other files in Apps/Playground/Android/app/src/main/assets/Scripts, and I needed to compile these files a second time to appear here. Could it be because the first compile time generated node_modules after copying the files?

@Cedric Maybe this PR needs to be improved a bit more, but it did solve my problem. Thanks again.

1 Like