Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.11.0, 5.12.0
-
macOS Sierra 10.12.5
Qt 5.11.0
Android 7.0
-
-
3c74042c3db8c68e47ed1f0c2ecd4d39a2d84912 (qt/qtbase/5.12)
Description
I have an Android application which uses some JNI to communicate between my Java and C++ classes. The JNI_OnLoad function looks something like this:
JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void */* reserved */) { qDebug() << "starting to register functions"; JNIEnv *env; if (vm->GetEnv(reinterpret_cast<void **>(&env), JNI_VERSION_1_6) != JNI_OK) { return JNI_ERR; } jclass nativeClass = env->FindClass("com/example/myapp/MainActivity"); if (!nativeClass) return JNI_ERR; if (env->RegisterNatives(nativeClass, mainActivityMethods, sizeof(mainActivityMethods) / sizeof(mainActivityMethods[0])) < 0) { return JNI_ERR; } qDebug() << "registered all functions!"; return JNI_VERSION_1_6; }
It is contained in a file which is definitely listed as a source file in the .pro file. However, the debug statements are never printed out and I get
java.lang.UnsatisfiedLinkError: No implementation found for java.lang.String com.example.myapp.MainActivity.foo() (tried Java_com_example_myapp_MainActivity_foo and Java_com_example_myapp_MainActivity_foo__)
I did not use to get this error before I upgraded to 5.11. Everything was working fine previously.
It is, however, worth noting that I also did a "VCS refresh" in the sense that I had to pull all the files from the repository into a fresh directory because the old one was deleted. This could potentially be a factor, though I don't think so.
I was able to manually resolve the error by adding a call to `System.loadLibrary("MyApp")` However, I was under the impression this was not supposed to be necessary. Therefore I believe it is a bug.
Attachments
Issue Links
- is duplicated by
-
QTBUG-68488 Android application crash at startup when calling native function in activity onResume
- Closed
-
QTBUG-66929 JNI_OnLoad is called only at first start
- Closed
For Gerrit Dashboard: QTBUG-68813 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
252757,3 | Load main library as soon as possible | 5.12 | qt/qtbase | Status: MERGED | +2 | 0 |
254158,1 | Load main library as soon as possible | 5.13 | qt/qtbase | Status: ABANDONED | 0 | 0 |