JNI_OnLoad returned bad version (-1)

匿名 (未验证) 提交于 2019-12-03 00:52:01

问题:

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!!!!

回答1:

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.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!