-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
5.11.2
-
None
-
* Windows Host
* Android target: Android x86 8.1 running on VM.
* Qt 5.11.2 Android x86 (official)
* NDK 16b
* SDK 28.x
Currently it is impossible to create an own custom plugins for Android, using JAVA/JAR files without of installing of this plugins to Qt location/directory.
I have attached an example, based on QtLocation's position plugin. In this plugin tries to call the static FooPositioning::getFoo() method from the compiled JAR class...
package com.bug.positioning; import android.util.Log; public class FooPositioning { private static final String TAG = "Foo"; static public int getFoo() { Log.d(TAG, "Get foo"); return 123; } }
When an application starts, it loads this custom plugin, and then tries to call the getFoo() method:
GeoPositionInfoSourceFoo::GeoPositionInfoSourceFoo(QObject *parent) : QGeoPositionInfoSource(parent) { const auto result = QAndroidJniObject::callStaticMethod<jint>( "com/bug/positioning/FooPositioning", "getFoo", "(I;)"); qCDebug(FOO_SRC) << "Result:" << result; }
, but can't found the FooPositioning class:
D libfooapp.so: (null):0 ((null)): loaded library "/data/data/org.qtproject.example.fooapp/qt-reserved-files/plugins/position/libposition_foo.so" W System.err: java.lang.ClassNotFoundException: Didn't find class "com.bug.positioning.FooPositioning" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib, /system/vendor/lib]] W System.err: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125) W System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:379) W System.err: at java.lang.ClassLoader.loadClass(ClassLoader.java:312) W System.err: at org.qtproject.qt5.android.QtNative.startQtApplication(Native Method) W System.err: at org.qtproject.qt5.android.QtNative$6.run(QtNative.java:359) W System.err: at org.qtproject.qt5.android.QtThread$1.run(QtThread.java:61) W System.err: at java.lang.Thread.run(Thread.java:764) D libfooapp.so: D:\Projects\My\plugin-bug\plugins\position\foo\src\geopositioninfosource_foo.cpp:16 (GeoPositionInfoSourceFoo::GeoPositionInfoSourceFoo(QObject*)): foo.src: Result: 0
I see my compiled JAR files in android-build directory:
d:\Projects\My\build-bug-debug\android-build\build\intermediates\jniLibs\debug\x86\FooPositioning.jar d:\Projects\My\build-bug-debug\android-build\libs\x86\FooPositioning.jar d:\Projects\My\build-bug-debug\plugins\position\foo\jar\FooPositioning.jar
but I did not see any its mention in generated AndroidManifest.xml file in:
<meta-data android:name="android.app.load_local_jars" android:value="jar/QtAndroid.jar:jar/QtAndroidBearer.jar:jar/QtPositioning.jar:jar/QtAndroidExtras.jar"/> <meta-data android:name="android.app.static_init_classes" android:value="org.qtproject.qt5.android.positioning.QtPositioning"/>