Minie for Androids

Oh I can see how that is contradicting.

  1. When I write my jME game code I use the jME sdk to create my game which means I need a jar library added and hence it is build using ANT.
  2. When I am happy to test my game on android I will create an android application in android studio which uses gradle and I reference the jme/heart/minie gradle dependencies there for the android build.

I hope this makes sense?

1 Like

Seeing that each libc++_shared.so is >4MB (and comes with a confusing license) I decided to specify the static version.

I hope this makes sense?

It does, thank you.

Before I rebuild the native libraries again, let’s see if we can persuade the NDK to include the shared libc++ runtime in your game. Instructions are here. Would you try that for me please, if you haven’t already?

I can’t figure out how to do this in my current android setup.

1 Like

Are you using CMake, or ndkBuild?

Well whatever android studio is making use of.
Let me investigate a bit more.

1 Like

Your build.gradle file should indicate. Look in the externalNativeBuild {} section.

I do not have that in my build.gradle file.

1 Like

OK, so let’s use CMake, since ndkBuild is deprecated.

https://developer.android.com/studio/projects/gradle-external-native-builds

Is there anything I might do to assist?

Hi @sgold,

Can you please assist in how I should configure the CMakeLists.txt file to accommodate for the C++ build?

This is what error I am getting on the txt file:

release|x86_64 :C:/work-proto/jme-minie-test/jme-minie-android/app/CMakeLists.txt:1:
release|x86_64 :Parse error.  Expected a command name, got unquoted argument with text "ANDROID_STL='c++_shared'".
1 Like

I think the CMakeLists.txt can be empty for now. Or if Android Studio insists on non-empty, add some harmless command like cmake_minimum_required(VERSION 3.0).

I believe we don’t want any addLibrary() commands in the CMakeLists.txt file, since both native libraries (libbulletjme.so and libc++_shared.so) are pre-built.

The key thing, I think, is to set android.defaultConfig.externalNativeBuild.cmake.arguments in the build.gradle file to 'ANDROID_STL=c++_shared'

I’d feel more confident if I could find a clear example of this, or at least something similar, on the Web.

I have done this and my code with the cmake stuff compiles now except it still gives the error:

E/AndroidRuntime: FATAL EXCEPTION: GLThread 1991
    Process: com.jme.minie.tests, PID: 18822
    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 1991,5,main]
    java.lang.UnsatisfiedLinkError: dlopen failed: library "libc++_shared.so" not found

1 Like

Thank you. I’d like to see the app/build.gradle file, please.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.jme.minie.tests"
        minSdkVersion 19
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    externalNativeBuild {
        cmake {
            path file('CMakeLists.txt')

        }
    }
}

project.ext {
    jmeVersion = "3.3.0-stable"
    gamePath = "../../jme-minie-game"
    androidNativeVersion = "3.3.0-alpha2"
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

    //jME dependencies
    implementation "org.jmonkeyengine:jme3-core:$jmeVersion"
    implementation "org.jmonkeyengine:jme3-android:$jmeVersion"
    implementation "org.jmonkeyengine:jme3-android-native:$androidNativeVersion"
//    implementation "org.jmonkeyengine:jme3-bullet-native-android:$jmeVersion"
    implementation "org.jmonkeyengine:jme3-effects:$jmeVersion"
    implementation "org.jmonkeyengine:jme3-plugins:$jmeVersion"


    //Minie dependencies
    implementation files(gamePath + '/dist/lib/Heart-5.2.1.jar')
    implementation files(gamePath + '/dist/lib/Minie-1.5.0.jar')

    //Pull in galago dependencies
    implementation files(gamePath + '/dist/lib/tween-engine-api.jar')
    implementation files(gamePath + '/dist/lib/Galago.jar')
    implementation files(gamePath + '/dist/jme-minie.jar')

}

An this is how I set it up in the cmakelist.txt

set(ANDROID_STL "${ANDROID_STL} c++_shared")

1 Like

I found a build.gradle on the Web that resembles what I’m trying to do here: Getting Started - Node.js for Mobile Apps

Inside that defaultConfig block, please add:

        externalNativeBuild {
            cmake {
                arguments '-DANDROID_STL=c++_shared'
            }
        }

Okay I have done this but it gives the same error.

1 Like

@ndebruyn: I appreciate your patience with the testing process. I’ll do some more research.

I think we might be stuck—or nearly so. I, for one, would welcome suggestions from other Android developers at this Forum. Help!

In order to avoid delaying the next Minie release, I might decide to postpone Android support until May, or even release it untested.

Okay @sgold. I really want to get this working from my side as well.

Can you maybe tell me where does this file lie? “libc++_shared.so”

Or where is it supposed to be?

1 Like

There’s a different version of libc++_shared.so for each ABI. The Android SDK installs copies under both “ndk-bundle” and “ndk”:

sgold:~/Android/Sdk$ find . -name 'libc++_shared.so' -print
./ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so
./ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/i686-linux-android/libc++_shared.so
./ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/x86_64-linux-android/libc++_shared.so
./ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/arm-linux-androideabi/libc++_shared.so
./ndk-bundle/sources/cxx-stl/llvm-libc++/libs/x86/libc++_shared.so
./ndk-bundle/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so
./ndk-bundle/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so
./ndk-bundle/sources/cxx-stl/llvm-libc++/libs/x86_64/libc++_shared.so
./ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/libc++_shared.so
./ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/i686-linux-android/libc++_shared.so
./ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/x86_64-linux-android/libc++_shared.so
./ndk/21.0.6113669/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/arm-linux-androideabi/libc++_shared.so
./ndk/21.0.6113669/sources/cxx-stl/llvm-libc++/libs/x86/libc++_shared.so
./ndk/21.0.6113669/sources/cxx-stl/llvm-libc++/libs/arm64-v8a/libc++_shared.so
./ndk/21.0.6113669/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so
./ndk/21.0.6113669/sources/cxx-stl/llvm-libc++/libs/x86_64/libc++_shared.so
sgold:~/Android/Sdk$

I recommend using the copies under “ndk/21.0.6113669/sources/cxx-stl/llvm-libc++/libs” since the Minie native libraries were compiled using that version of the NDK.