benlau / androidnative.pri

Calling Android functions from Qt without using JNI
Apache License 2.0
103 stars 15 forks source link

java.lang.UnsatisfiedLinkError #18

Closed ghost closed 5 years ago

ghost commented 6 years ago

Compiling with Qt 5.11 gives java.lang.UnsatisfiedLinkError: No implementation found for void androidnative.SystemDispatcher.jniEmit(java.lang.String, java.util.Map) (tried Java_androidnative_SystemDispatcher_jniEmit and Java_androidnative_SystemDispatcher_jniEmit__Ljava_langString...) Compiling with 5.10 compiles successfully. I have the following text in main.cpp

ifdef Q_OS_ANDROID

include <QtAndroidExtras/QAndroidJniObject>

include <QtAndroidExtras/QAndroidJniEnvironment>

JNIEXPORT jint JNI_OnLoad(JavaVM vm, void) { Q_UNUSED(vm); qDebug("NativeInterface::JNI_OnLoad()"); // It must call this function within JNI_OnLoad to enable System Dispatcher

AndroidNative::SystemDispatcher::registerNatives(); return JNI_VERSION_1_6; }

endif

isokolovskii commented 6 years ago

Same as Issue #19

Problem looks like a bug in Qt 5.11.0 due to jni_onLoad no being called like ever. Workaround is to add to main activity onCreate function call to System.loadLibrary. Name of library is eventually name of your target set in .pro file. So it's like System.loadLibrary("TargetName").

Issue should be marked closed.