JOGL in Android- java.lang.UnsatisfiedLinkError

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

JOGL in Android- java.lang.UnsatisfiedLinkError

kaeffin
Hello,

I want to use JOGL in a Androidstudioproject. I use the following Gradlecode to add JOGL to my project.

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.example.myapplication"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile "org.jogamp.gluegen:gluegen-rt:2.3.1"
    compile "org.jogamp.jogl:jogl-all:2.3.1"

    compile "org.jogamp.gluegen:gluegen-rt:2.3.1:natives-android-aarch64"
    compile "org.jogamp.gluegen:gluegen-rt:2.3.1:natives-android-armv6"
    compile "org.jogamp.gluegen:gluegen-rt:2.3.1:natives-linux-amd64"
    compile "org.jogamp.gluegen:gluegen-rt:2.3.1:natives-linux-armv6"
    compile "org.jogamp.gluegen:gluegen-rt:2.3.1:natives-linux-armv6hf"
    compile "org.jogamp.gluegen:gluegen-rt:2.3.1:natives-linux-i586"
    compile "org.jogamp.gluegen:gluegen-rt:2.3.1:natives-macosx-universal"
    compile"org.jogamp.gluegen:gluegen-rt:2.3.1:natives-solaris-amd64"
    compile "org.jogamp.gluegen:gluegen-rt:2.3.1:natives-solaris-i586"
    //compile "org.jogamp.gluegen:gluegen-rt:2.3.1:natives-windows-amd64"
    compile "org.jogamp.gluegen:gluegen-rt:2.3.1:natives-windows-i586"

    compile "org.jogamp.jogl:jogl-all:2.3.1:natives-android-aarch64"
    compile "org.jogamp.jogl:jogl-all:2.3.1:natives-android-armv6"
    compile "org.jogamp.jogl:jogl-all:2.3.1:natives-linux-amd64"
    compile "org.jogamp.jogl:jogl-all:2.3.1:natives-linux-armv6"
    compile "org.jogamp.jogl:jogl-all:2.3.1:natives-linux-armv6hf"
    compile "org.jogamp.jogl:jogl-all:2.3.1:natives-linux-i586"
    compile "org.jogamp.jogl:jogl-all:2.3.1:natives-macosx-universal"
    compile "org.jogamp.jogl:jogl-all:2.3.1:natives-solaris-amd64"
    compile "org.jogamp.jogl:jogl-all:2.3.1:natives-solaris-i586"
    //compile "org.jogamp.jogl:jogl-all:2.3.1:natives-windows-amd64"
    compile "org.jogamp.jogl:jogl-all:2.3.1:natives-windows-i586"
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
}

But when i want to run the app:


FATAL EXCEPTION: main
                                                                                    Process: com.example.praktikant.myapplication, PID: 2408
                                                                                    java.lang.UnsatisfiedLinkError: dlopen failed: library "//libgluegen-rt.so" not found
                                                                                        at java.lang.Runtime.load(Runtime.java:332)
                                                                                        at java.lang.System.load(System.java:1069)
                                                                                        at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoaderBase.java:596)
                                                                                        at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.java:63)
                                                                                        at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNILibLoaderBase.java:95)
                                                                                        at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.java:459)
                                                                                        at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrary(DynamicLibraryBundle.java:421)
                                                                                        at com.jogamp.common.os.Platform$1.run(Platform.java:317)
                                                                                        at java.security.AccessController.doPrivileged(AccessController.java:45)
                                                                                        at com.jogamp.common.os.Platform.<clinit>(Platform.java:287)
                                                                                        at com.jogamp.common.os.Platform.initSingleton(Platform.java:355)
                                                                                        at com.jogamp.opengl.GLProfile.<clinit>(GLProfile.java:146)


Does anyone have an approach what might be the cause?
Reply | Threaded
Open this post in threaded view
|

Re: JOGL in Android- java.lang.UnsatisfiedLinkError

gouessej
Administrator
Hi

Please use JOGL 2.3.2. If you find a bug, we'll be able to help you only if you use the latest version.

You can look at the Gradle build scripts in LibGDX and JogAmp's Ardor3D Continuation to check whether we do something particular but I don't use them for Android yet. I remember that my Gradle scripts were a lot more simple.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL in Android- java.lang.UnsatisfiedLinkError

kaeffin
Thank you for your answer.

Now I use 2.3.2. But the Error is the same.
Is that a problem that I use a 32bit Java version?
Reply | Threaded
Open this post in threaded view
|

Re: JOGL in Android- java.lang.UnsatisfiedLinkError

gouessej
Administrator
No it should work with the 32-bit JDK too. The JARs containing the native libraries must be in the same directory than the JARs containing the Java libraries.

You can look at my short Gradle build file:
https://github.com/gouessej/Ardor3D/blob/master/ardor3d-jogl/build.gradle
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL in Android- java.lang.UnsatisfiedLinkError

gouessej
Administrator
In reply to this post by kaeffin
Reply | Threaded
Open this post in threaded view
|

Re: JOGL in Android- java.lang.UnsatisfiedLinkError

kaeffin
In reply to this post by gouessej
Now i added these two lines:

 compile group: 'org.jogamp.gluegen', name: 'gluegen-rt-main', version:'2.3.2'
 compile group: 'org.jogamp.jogl', name: 'jogl-all-main', version:'2.3.2'

But the Error is the same.

FATAL EXCEPTION: main
                                                                                    Process: com.example.praktikant.myapplication, PID: 2688
                                                                                    java.lang.UnsatisfiedLinkError: dlopen failed: library "//natives/android-i586//libgluegen-rt.so" not found
                                                                                        at java.lang.Runtime.load(Runtime.java:332)
                                                                                        at java.lang.System.load(System.java:1069)
                                                                                        at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoaderBase.java:624)
                                                                                        at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.java:63)
                                                                                        at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNILibLoaderBase.java:106)
                                                                                        at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.java:487)
                                                                                        at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrary(DynamicLibraryBundle.java:421)
                                                                                        at com.jogamp.common.os.Platform$1.run(Platform.java:317)
                                                                                        at java.security.AccessController.doPrivileged(AccessController.java:45)
                                                                                        at com.jogamp.common.os.Platform.<clinit>(Platform.java:287)
                                                                                        at com.jogamp.common.os.Platform.initSingleton(Platform.java:355)
                                                                                        at com.jogamp.opengl.GLProfile.<clinit>(GLProfile.java:147)
                                                                                        at visualisierung.visu.<init>(visu.java:28)
                                                                                        at creation.boxCreation.<init>(boxCreation.java:85)
                                                                                        at com.example.praktikant.myapplication.MainActivity.onCreate(MainActivity.java:26)
                                                                                        at android.app.Activity.performCreate(Activity.java:6237)
                                                                                        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107)
                                                                                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369)
                                                                                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
                                                                                        at android.app.ActivityThread.-wrap11(ActivityThread.java)
                                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
                                                                                        at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                        at android.os.Looper.loop(Looper.java:148)
                                                                                        at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                                        at java.lang.reflect.Method.invoke(Native Method)
                                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

What is the libgluegen-rt.so file ? and why my android studio can't find it?
Reply | Threaded
Open this post in threaded view
|

Re: JOGL in Android- java.lang.UnsatisfiedLinkError

kaeffin
I did like your second link.

And now the errormessage is :

 java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app/com.example.praktikant.myapplication-2/lib/x86/libgluegen-rt.so" has unexpected e_machine: 40
Reply | Threaded
Open this post in threaded view
|

Re: JOGL in Android- java.lang.UnsatisfiedLinkError

gouessej
Administrator
You cannot use exactly the same JARs for Android development and desktop development. You have to use jogl-all-android and gluegen-rt-android for Android.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL in Android- java.lang.UnsatisfiedLinkError

kaeffin
Yes, that's clear to me.

Can you tell something about my error message which i have posted?
Reply | Threaded
Open this post in threaded view
|

Re: JOGL in Android- java.lang.UnsatisfiedLinkError

gouessej
Administrator
When you mix desktop and Android JARs, GlueGen tries to use the desktop version to load the native libraries for GNU Linux instead of using Android native libraries.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL in Android- java.lang.UnsatisfiedLinkError

kaeffin
I updated the gradle file again to :

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.example.praktikant.myapplication"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            zipAlignEnabled true
        }
        debug {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules-debug.pro'
            zipAlignEnabled true
        }
    }
}
dependencies {
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile files('libs/mxparser.jar')
    compile files('libs/gson-2.1.jar')
    compile files('libs/gluegen-rt-android.jar')
    compile files('libs/gluegen-rt-natives-android-armv6.jar')
    compile files('libs/jogl-all-android.jar')
    compile files('libs/jogl-all-natives-android-armv6.jar')
}

Now there isn't a windows or linux data.
I create a folder in : MyApplication/app/sry/main/jniLibs/android-i586/ and there i put the libgluegen-rt.so from the gluegen natives.

But the error is:

java.lang.UnsatisfiedLinkError: dlopen failed: "/data/app/com.example.praktikant.myapplication-1/lib/x86/libgluegen-rt.so" has unexpected e_machine: 40

Reply | Threaded
Open this post in threaded view
|

Re: JOGL in Android- java.lang.UnsatisfiedLinkError

gouessej
Administrator
You mustn't put the native libraries into another directory. This is GlueGen's responsibility to extract and load the right native libraries from the JARs.

If you don't succeed in using Android Studio with Gradle, I advise you to use the same environment than other Android developers using JOGL:
http://forum.jogamp.org/Recreating-Jogl2-Android-demo-projects-in-Eclipse-td4027079.html#a4027138

Please don't compile the JARs containing the native libraries, it makes no sense.
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: JOGL in Android- java.lang.UnsatisfiedLinkError

kaeffin
ok thank you for this. I think i found out what exactly the problem is.

I create a new directory like the instructions of :

http://forum.jogamp.org/Gluegen-apk-won-t-install-on-Android-6-Marshmallow-td4036114.html#a4036185

The problem is that i use a x86 virtual device and I haven't any idea what native file i have to choose.

Can someone tell me which native is the right one?

I search for something like : gluegen-rt-natives-android-i586.jar

but the i586 versions are only for windows,solaris and linux.

Reply | Threaded
Open this post in threaded view
|

Re: JOGL in Android- java.lang.UnsatisfiedLinkError

gouessej
Administrator
I don't think that we have a build supporting x86 architecture under Android yet.
Julien Gouesse | Personal blog | Website