benlau / androidnative.pri Goto Github PK
View Code? Open in Web Editor NEWCalling Android functions from Qt without using JNI
License: Apache License 2.0
Calling Android functions from Qt without using JNI
License: Apache License 2.0
After installing package via qpm with install instructions provided and adding SystemDispatcher.dispatch call in my custom main activity I get runtime error:
E AndroidRuntime: 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_lang_String_2Ljava_util_Map_2)
E AndroidRuntime: at androidnative.SystemDispatcher.jniEmit(Native Method)
E AndroidRuntime: at androidnative.SystemDispatcher.emit(SystemDispatcher.java:161)
E AndroidRuntime: at androidnative.SystemDispatcher.dispatch(SystemDispatcher.java:66)
E AndroidRuntime: at androidnative.SystemDispatcher.dispatch(SystemDispatcher.java:40)
E AndroidRuntime: at ru.maxnet.activity.MyActivity.onCreate(MyActivity.java:29)
E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:7023)
E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:7014)
E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2745)
E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2870)
E AndroidRuntime: at android.app.ActivityThread.-wrap11(Unknown Source:0)
E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1601)
E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106)
E AndroidRuntime: at android.os.Looper.loop(Looper.java:172)
E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:6590)
E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
I am using Qt 5.11.0, android SDK 27 and running it on armv-7a arch device. Need a helping hand with fixing it as for now nothing I found doing wrong.
Hi @benlau,
An interesting and great alternative way of making Java/Android function calls instead of using JNI !
This library supports connectivity with Java (non-Android) applications and how it can be achieved that? Maybe by using SystemDispatcher message queue?
Also, have you tested if the library is compatible with Qt 5.15?
Thanks.
I am a little confused regarding the "up to date"-ness of the qpm package? In qpm, it's version 0.0.4, in your github qpm file, it states 0.0.5, and on your release page you are already at version 0.1.7
Is the qpm package simply not up to date? Or how do I have to understand those versions?
AndroidRuntime: 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_lang_String_2Ljava_util_Map_2)
seems that JNI_onLoad is not called
When im trying to use it on android 25, then i got the error as in the title. Is there any hope it will be working for the newest targets?
anyway, great package. thank you!
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_lang_String_...) 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
a step is missing :
qpm install
on root folder prior to build. ( it needs quickandroid)
I have a proplem with ImagePicker. onActivityResult method not being called. ImagePicker recieve from SystemDispatcher 3 messages: androidnative.SystemDispatcher.loadClass, androidnative.ImagePicker.pickImage and after them androidnative.Activity.onResume. I use API 19, and latest version Android SDK and NDK.
I was glas to find this package. This package really best way to use android native in Qt without JNI. Thank you.
I tried it for app and I got the error:
qrc:/main.qml:14 ((null)): qrc:/main.qml:14:25: Unable to assign int to QQuickAnchorLine
It linked to initialPage: Components
, it didn't recognize this.
I also couldn't run the example app, it gave error:
../androidnativeexample/main.cpp:7:32: fatal error: qadrawableprovider.h: No such file or directory
#include "qadrawableprovider.h"
I read your blog about splash screen for Android and came here directly, Thanks
Hi it would be nice if AndroidNative could be used for Android Intents (share to Qt/QML APP). I only get the type "androidnative.Activity.onResume" and an empty object as message.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.