Minie for Androids

Yes. Here are the download links:
Release 5.2.1 · stephengold/Heart · GitHub

You want Heart-5.2.1.jar, of course.

1 Like

As it uses plugin version 2.2.0

I have not tested to see if it is compatible with gradle-5.4.1-bin.zip that you have submitted in your PR. I was suggesting gradle 5.4.1 for android plugin 3.5.0 that I am using in the modified build.gradle.
btw, you can find required Gradle version for each plugin version here:

Thanks @sgold, I got it working on the sdk. Now to compile to android and see how it goes.

1 Like

Ok this is the output I get when running on the emulator.
It fails to start create the physics space.

E/jme.minie.test: No implementation found for long com.jme3.bullet.PhysicsSpace.createPhysicsSpace(float, float, float, float, float, float, int) (tried Java_com_jme3_bullet_PhysicsSpace_createPhysicsSpace and Java_com_jme3_bullet_PhysicsSpace_createPhysicsSpace__FFFFFFI)
E/AndroidRuntime: FATAL EXCEPTION: GLThread 1876
    Process: com.jme.minie.tests, PID: 11341
    java.lang.UnsatisfiedLinkError: No implementation found for long com.jme3.bullet.PhysicsSpace.createPhysicsSpace(float, float, float, float, float, float, int) (tried Java_com_jme3_bullet_PhysicsSpace_createPhysicsSpace and Java_com_jme3_bullet_PhysicsSpace_createPhysicsSpace__FFFFFFI)
        at com.jme3.bullet.PhysicsSpace.createPhysicsSpace(Native Method)
        at com.jme3.bullet.PhysicsSpace.create(PhysicsSpace.java:810)
        at com.jme3.bullet.CollisionSpace.<init>(CollisionSpace.java:148)
        at com.jme3.bullet.PhysicsSpace.<init>(PhysicsSpace.java:254)
        at com.jme3.bullet.BulletAppState.createPhysicsSpace(BulletAppState.java:627)
        at com.jme3.bullet.BulletAppState.startPhysics(BulletAppState.java:567)
        at com.jme3.bullet.BulletAppState.stateAttached(BulletAppState.java:795)
        at com.jme3.app.state.AppStateManager.attach(AppStateManager.java:148)
        at com.bruynhuis.galago.app.Base3DApplication.initPhysics(Base3DApplication.java:52)
        at com.bruynhuis.galago.app.BaseApplication.simpleUpdate(BaseApplication.java:424)
        at com.jme3.app.SimpleApplication.update(SimpleApplication.java:258)
        at com.jme3.app.AndroidHarness.update(AndroidHarness.java:496)
        at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:354)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1573)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1272)
E/com.jme3.app.AndroidHarness: SEVERE Exception thrown in Thread[GLThread 1876,5,main]
    java.lang.UnsatisfiedLinkError: No implementation found for long com.jme3.bullet.PhysicsSpace.createPhysicsSpace(float, float, float, float, float, float, int) (tried Java_com_jme3_bullet_PhysicsSpace_createPhysicsSpace and Java_com_jme3_bullet_PhysicsSpace_createPhysicsSpace__FFFFFFI)
        at com.jme3.bullet.PhysicsSpace.createPhysicsSpace(Native Method)
        at com.jme3.bullet.PhysicsSpace.create(PhysicsSpace.java:810)
        at com.jme3.bullet.CollisionSpace.<init>(CollisionSpace.java:148)
        at com.jme3.bullet.PhysicsSpace.<init>(PhysicsSpace.java:254)
        at com.jme3.bullet.BulletAppState.createPhysicsSpace(BulletAppState.java:627)
        at com.jme3.bullet.BulletAppState.startPhysics(BulletAppState.java:567)
        at com.jme3.bullet.BulletAppState.stateAttached(BulletAppState.java:795)
        at com.jme3.app.state.AppStateManager.attach(AppStateManager.java:148)
        at com.bruynhuis.galago.app.Base3DApplication.initPhysics(Base3DApplication.java:52)
        at com.bruynhuis.galago.app.BaseApplication.simpleUpdate(BaseApplication.java:424)
        at com.jme3.app.SimpleApplication.update(SimpleApplication.java:258)
        at com.jme3.app.AndroidHarness.update(AndroidHarness.java:496)
        at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:354)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1573)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1272)
D/EGL_emulation: eglMakeCurrent: 0xebd50220: ver 2 0 (tinfo 0xebddac70)
D/EGL_emulation: eglMakeCurrent: 0xebd50220: ver 2 0 (tinfo 0xebddac70)
E/jme.minie.test: No implementation found for void com.jme3.bullet.CollisionSpace.finalizeNative(long) (tried Java_com_jme3_bullet_CollisionSpace_finalizeNative and Java_com_jme3_bullet_CollisionSpace_finalizeNative__J)
E/System: Uncaught exception thrown by finalizer
E/System: java.lang.UnsatisfiedLinkError: No implementation found for void com.jme3.bullet.CollisionSpace.finalizeNative(long) (tried Java_com_jme3_bullet_CollisionSpace_finalizeNative and Java_com_jme3_bullet_CollisionSpace_finalizeNative__J)
        at com.jme3.bullet.CollisionSpace.finalizeNative(Native Method)
        at com.jme3.bullet.CollisionSpace.finalize(CollisionSpace.java:600)
        at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:289)
        at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:276)
        at java.lang.Daemons$Daemon.run(Daemons.java:137)
        at java.lang.Thread.run(Thread.java:919)
D/EGL_emulation: eglMakeCurrent: 0xebd50220: ver 2 0 (tinfo 0xebddac70)
1 Like

@Ali_RS: Thank you for that information. As I suspected, building an Android app with JMonkeyEngine is not “easy to do”. That’s why I asked for help, someone experienced to run some tests for me.

1 Like

That’s an interesting failure. I’ll investigate at my end.

  1. What ABI were you emulating?
  2. Did the “Libbulletjme v5.5.3 initializing” message appear anywhere in the standard output? Or did “Bullet-Native: Initializing java classes” appear there instead?
  3. If neither of those message appeared, try loading the native library explicitly, by invoking System.loadLibrary("bulletjme"); prior to creating the PhysicsSpace.
  1. I am emulating Galaxy Nexus API 29 (In jME JmeSystem.getPlatform() returns Android_Other).
  2. It did not print the text “Libbulletjme v5.5.3 initializing” in android but it did print when running on PC.
  3. It can’t load the bulletjme library I am getting the error below:
E/AndroidRuntime: FATAL EXCEPTION: GLThread 1922
    Process: com.jme.minie.tests, PID: 13850
    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.jme.minie.tests-uIccetXyFomI2tX5ZYz6gQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.jme.minie.tests-uIccetXyFomI2tX5ZYz6gQ==/lib/x86, /data/app/com.jme.minie.tests-uIccetXyFomI2tX5ZYz6gQ==/base.apk!/lib/x86, /system/lib, /system/product/lib]]] couldn't find "libbulletjme.so"
        at java.lang.Runtime.loadLibrary0(Runtime.java:1067)
        at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
        at java.lang.System.loadLibrary(System.java:1667)
        at com.bruynhuis.galago.app.Base3DApplication.initPhysics(Base3DApplication.java:55)
        at com.bruynhuis.galago.app.BaseApplication.simpleUpdate(BaseApplication.java:424)
        at com.jme3.app.SimpleApplication.update(SimpleApplication.java:258)
        at com.jme3.app.AndroidHarness.update(AndroidHarness.java:496)
        at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:354)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1573)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1272)
E/com.jme3.app.AndroidHarness: SEVERE Exception thrown in Thread[GLThread 1922,5,main]
    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.jme.minie.tests-uIccetXyFomI2tX5ZYz6gQ==/base.apk"],nativeLibraryDirectories=[/data/app/com.jme.minie.tests-uIccetXyFomI2tX5ZYz6gQ==/lib/x86, /data/app/com.jme.minie.tests-uIccetXyFomI2tX5ZYz6gQ==/base.apk!/lib/x86, /system/lib, /system/product/lib]]] couldn't find "libbulletjme.so"
        at java.lang.Runtime.loadLibrary0(Runtime.java:1067)
        at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
        at java.lang.System.loadLibrary(System.java:1667)
        at com.bruynhuis.galago.app.Base3DApplication.initPhysics(Base3DApplication.java:55)
        at com.bruynhuis.galago.app.BaseApplication.simpleUpdate(BaseApplication.java:424)
        at com.jme3.app.SimpleApplication.update(SimpleApplication.java:258)
        at com.jme3.app.AndroidHarness.update(AndroidHarness.java:496)
        at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:354)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1573)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1272)
D/EGL_emulation: eglMakeCurrent: 0xe3c1a120: ver 2 0 (tinfo 0xe3c0f170)
D/EGL_emulation: eglMakeCurrent: 0xe3c1a120: ver 2 0 (tinfo 0xe3c0f170)

2 Likes

Okay I figured out the emulators ABI.

It is x86.

2 Likes

Hm. According to WIkipedia, the Galaxy Nexus had an ARM Cortex-A9 CPU, so I’d expect the ABI to be armeabi-v7a.

In any case, the value returned by JmeSystem.getPlatform() shouldn’t matter, since System.loadLibrary() is supposed to pick the correct native library image based on the platform’s ABI. (jme3-android loads native libraries quite differently from jme3-desktop.)

I read at stackoverflow.com that the 32-bit ARM library needs to be under both armeabi and armeabi-v7a. Currently it’s only under armeabi-v7a, which might be the issue here.

To determine whether the issue you’re seeing is ABI-specific, please re-test on a different emulated device, one with a 64-bit ABI.

Never mind, I think I found the bug. The Android native libraries need to be under lib:

$ unzip -l *.jar
Archive:  jme3-bullet-native-android-3.3.0-stable.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  2020-03-30 08:41   META-INF/
      100  2020-03-30 08:41   META-INF/MANIFEST.MF
        0  2020-03-30 08:41   lib/
        0  2020-03-30 08:41   lib/x86/
  3635812  2020-03-30 08:41   lib/x86/libbulletjme.so
        0  2020-03-30 08:41   lib/x86_64/
  3882488  2020-03-30 08:41   lib/x86_64/libbulletjme.so
        0  2020-03-30 08:41   lib/armeabi-v7a/
  2374232  2020-03-30 08:41   lib/armeabi-v7a/libbulletjme.so
        0  2020-03-30 08:41   lib/arm64-v8a/
  3046600  2020-03-30 08:41   lib/arm64-v8a/libbulletjme.so
---------                     -------
 12939232                     11 files

But Minie currently has them without the lib component. I’ll fix and let you know when to re-test.

1 Like

Okay, test this newer commit:

cd Minie
git checkout -b test fd46f46d
./gradlew clean build

Now I am getting this when calling System.loadLibrary()

E/AndroidRuntime: FATAL EXCEPTION: GLThread 1966
    Process: com.jme.minie.tests, PID: 16854
    java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
        at java.lang.Runtime.loadLibrary0(Runtime.java:1071)
        at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
        at java.lang.System.loadLibrary(System.java:1667)
        at com.jme.minie.tests.MainApplication.initPhysics(MainApplication.java:43)
        at com.bruynhuis.galago.app.BaseApplication.simpleUpdate(BaseApplication.java:424)
        at com.jme3.app.SimpleApplication.update(SimpleApplication.java:258)
        at com.jme3.app.AndroidHarness.update(AndroidHarness.java:496)
        at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:354)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1573)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1272)
E/com.jme3.app.AndroidHarness: SEVERE Exception thrown in Thread[GLThread 1966,5,main]
    java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
        at java.lang.Runtime.loadLibrary0(Runtime.java:1071)
        at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
        at java.lang.System.loadLibrary(System.java:1667)
        at com.jme.minie.tests.MainApplication.initPhysics(MainApplication.java:43)
        at com.bruynhuis.galago.app.BaseApplication.simpleUpdate(BaseApplication.java:424)
        at com.jme3.app.SimpleApplication.update(SimpleApplication.java:258)
        at com.jme3.app.AndroidHarness.update(AndroidHarness.java:496)
        at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:354)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1573)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1272)
2 Likes

i think this one is more about linux(android in this case) missing libc lib(since you compile, not just use), or maybe it try get it from wrong location somehow.

Thank you @ndebruyn for that information.

There was a warning while building the native library that’s probably related:

Build bulletjme_armeabi-v7a
Android NDK: WARNING:/home/travis/build/stephengold/Libbulletjme/Android.mk:bulletjme: non-system libraries in linker flags: -lc++    
Android NDK:     This is likely to result in incorrect builds. Try using LOCAL_STATIC_LIBRARIES    
Android NDK:     or LOCAL_SHARED_LIBRARIES instead to list the library dependencies of the    
Android NDK:     current module    

I don’t see how to avoid this. If libc++ isn’t a system library, then what is it?

LOCAL_SHARED_LIBRARIES seems intended for user-built libraries.

I expected the clang linker to add libc++ automatically, but no—if I omit the -lc++ then there are undefined symbols in the link:

[armeabi-v7a] SharedLibrary  : libbulletjme.so
src/main/native/bullet3/BulletSoftBody/btDeformableBodySolver.cpp:0: error: undefined reference to 'std::__ndk1::cout'
src/main/native/bullet3/BulletSoftBody/btDeformableBodySolver.cpp:0: error: undefined reference to 'std::__ndk1::cout'
src/main/native/bullet3/BulletSoftBody/btConjugateGradient.h:0: error: undefined reference to 'std::__ndk1::cout'
 [...]
src/main/native/v-hacd/src/VHACD-ASYNC.cpp:267: error: undefined reference to 'std::__ndk1::mutex::lock()'
src/main/native/v-hacd/src/VHACD-ASYNC.cpp:270: error: undefined reference to 'std::__ndk1::mutex::unlock()'
src/main/native/v-hacd/src/VHACD-ASYNC.cpp:275: error: undefined reference to 'std::__ndk1::mutex::lock()'
src/main/native/v-hacd/src/VHACD-ASYNC.cpp:278: error: undefined reference to 'std::__ndk1::mutex::unlock()'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

I’ll research this some more.

Edit: I found this: https://developer.android.com/ndk/guides/cpp-support

Edit: Okay, I think I got this one. Even though I’m not building an application, I still need to supply an Application.mk file. That’s where I specify the libc++ I want. Which is called an STL. Which stands for Standard Template Library.

@ndebruyn We’re making progress. I’m very excited!

Please test this newer commit:

cd Minie
git checkout -b test2 d141694d
./gradlew clean build

1 Like

@sgold, I have tested with this new version and I am still getting an error. This is the error:

System.out: >> Before Loading lib : bulletjme
    
    --------- beginning of crash
2020-04-06 07:19:17.346 17911-17951/com.jme.minie.tests E/AndroidRuntime: FATAL EXCEPTION: GLThread 1976
    Process: com.jme.minie.tests, PID: 17911
    java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
        at java.lang.Runtime.loadLibrary0(Runtime.java:1071)
        at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
        at java.lang.System.loadLibrary(System.java:1667)
        at com.jme.minie.tests.MainApplication.initPhysics(MainApplication.java:43)
        at com.bruynhuis.galago.app.BaseApplication.simpleUpdate(BaseApplication.java:424)
        at com.jme3.app.SimpleApplication.update(SimpleApplication.java:258)
        at com.jme3.app.AndroidHarness.update(AndroidHarness.java:496)
        at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:354)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1573)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1272)
2020-04-06 07:19:17.347 17911-17951/com.jme.minie.tests E/com.jme3.app.AndroidHarness: SEVERE Exception thrown in Thread[GLThread 1976,5,main]
    java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found
        at java.lang.Runtime.loadLibrary0(Runtime.java:1071)
        at java.lang.Runtime.loadLibrary0(Runtime.java:1007)
        at java.lang.System.loadLibrary(System.java:1667)
        at com.jme.minie.tests.MainApplication.initPhysics(MainApplication.java:43)
        at com.bruynhuis.galago.app.BaseApplication.simpleUpdate(BaseApplication.java:424)
        at com.jme3.app.SimpleApplication.update(SimpleApplication.java:258)
        at com.jme3.app.AndroidHarness.update(AndroidHarness.java:496)
        at com.jme3.system.android.OGLESContext.onDrawFrame(OGLESContext.java:354)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1573)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1272)
2020-04-06 07:19:17.425 17911-17948/com.jme.minie.tests D/EGL_emulation: eglMakeCurrent: 0xebd5fe80: ver 2 0 (tinfo 0xebdf8c50)
2020-04-06 07:19:17.772 17911-17948/com.jme.minie.tests D/EGL_emulation: eglMakeCurrent: 0xebd5fe80: ver 2 0 (tinfo 0xebdf8c50)
2020-04-06 07:19:17.790 17911-17948/com.jme.minie.tests D/EGL_emulation: eglMakeCurrent: 0xebd5fe80: ver 2 0 (tinfo 0xebdf8c50)
2020-04-06 07:19:47.365 17911-17923/com.jme.minie.tests I/jme.minie.test: Thread[6,tid=17923,WaitingInMainSignalCatcherLoop,Thread*=0xe3c2a800,peer=0x15a002d8,"Signal Catcher"]: reacting to signal 3
2020-04-06 07:19:47.417 17911-17923/com.jme.minie.tests I/jme.minie.test: Wrote stack traces to tombstoned
1 Like

Hm. The “C++ Library Support” page says:

If you use libc++_shared.so, it must be included in your APK. If you’re building your application with Gradle this is handled automatically.

Even if that last statement is true (which I doubt) it leaves me wondering how to support ANT builds. I could add libc++_shared.so for each of the 4 ABIs to the Minie JAR, but that might break Gradle builds. Or I could specify the static version of libc++ during the native build, but that might break applications that include multiple shared libraries (which is just about every JME application).

So when I build my android code I am using gradle to build and not ant.
This is just as a side note.

I’m confused:

I am not using gradle as build system, I am using ant and the sdk.
Should I just manually download Heart?

So when I build my android code I am using gradle to build and not ant.
This is just as a side note.

Please clarify.