Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JNI_OnLoad returned bad version (-1)

I'm trying to load the Qt5Core library in my Android application and I get this:

JNI_OnLoad returned bad version (-1) in /data/data/com.xxx.yyy/lib/libQt5Core.so 0x41a8f3c0
Failed to load library : Qt5Core due to link error unknown failure
java.lang.UnsatisfiedLinkError: unknown failure
at java.lang.Runtime.loadLibrary(Runtime.java:370)

This is the way how I'm trying to load it:

System.loadLibrary(s);

where "s" is an array containing several library names. The other libraries are loaded correctly..

Any ideas are welcome!


EDIT

SO I'm getting this first:

D/dalvikvm(11445): Trying to load lib /data/app-lib/com.xxx.yyy/libQt5Core.so 0x42666fd8
D/dalvikvm(11445): Added shared lib /data/app-lib/com.xxx.yyy/libQt5Core.so 0x42666fd8

E/LibrariesLoader(11445): Failed to load library : Qt5Core due to link error JNI_ERR returned from JNI_OnLoad in "/data/app-lib/com.xxx.yyy/libQt5Core.so"

E/LibrariesLoader(11445): java.lang.UnsatisfiedLinkError: JNI_ERR returned from JNI_OnLoad in "/data/app-lib/com.xxx.yyy/libQt5Core.so"

...then there is another library which is loaded without any error/warning. That library has Qt5Core.so as dependency.

I have investigated and I'm getting this JNI_ERR because of the following code:

if (vm->GetEnv(&uenv.venv, JNI_VERSION_1_6) != JNI_OK)
return JNI_ERR;

The version of JNI that I'm using is 1.6!!!!

like image 700
Traian Avatar asked Aug 12 '14 11:08

Traian


1 Answers

QtCore's JNI_OnLoad loads an activity called "QtNative" when it starts and returns JNI_ERR if it is not found.

QtNative is defined in "QtAndroid-bundled.jar". You can find it in your QT 5.3 SDK folder: Qt5/5.3/android_armv7/jar/QtAndroid-bundled.jar

Just add this to your project's "libs" folder.

like image 73
Jim Avatar answered Oct 03 '22 08:10

Jim