Testing Android APK with QtCreator fails with an error.
-
Personally I use Qt5 but there is the same filosofy, you don't need rebuild Qt for support for ssl, you need only the library
https://github.com/KDAB/android_openssl
In this there are the library of open ssl for Qt -
Ok, I have now been given the correct way to include ssl in my Qt6 build [https://forum.qt.io/topic/162514/building-qt-6.9.1-for-android-with-ssl-support.].
As part of that excercise I have changed some of the system packages specifically:
jdk-17.0.12 and NDK 27.2.12479018.My android Qt build is in /opt/qt-android as before and if I run /opt/qt-android/bin/qmake6 against my QtTest.pro file and run make I get a arm64-v8a build.
If I try and build using qtcreator even though I think I have reconfigured it for the new jdk and ndk and have given it /opt/qt-android for the Qt environment it errors with:14:52:44: No Qt version configured.
14:52:44: Error while building/deploying project QtTest (kit: Qt 6.9.1 (qt-6.9.1))
14:52:44: When executing step "qmake"Obviously I have miss configured my QtCreator setup when I introduced these changes but I cannot see where, any suggestions are welcome.
-
Ok, I have now been given the correct way to include ssl in my Qt6 build [https://forum.qt.io/topic/162514/building-qt-6.9.1-for-android-with-ssl-support.].
As part of that excercise I have changed some of the system packages specifically:
jdk-17.0.12 and NDK 27.2.12479018.My android Qt build is in /opt/qt-android as before and if I run /opt/qt-android/bin/qmake6 against my QtTest.pro file and run make I get a arm64-v8a build.
If I try and build using qtcreator even though I think I have reconfigured it for the new jdk and ndk and have given it /opt/qt-android for the Qt environment it errors with:14:52:44: No Qt version configured.
14:52:44: Error while building/deploying project QtTest (kit: Qt 6.9.1 (qt-6.9.1))
14:52:44: When executing step "qmake"Obviously I have miss configured my QtCreator setup when I introduced these changes but I cannot see where, any suggestions are welcome.
Going to answer my own question here, for other reasons I had to reboot my android system on re-entering qtcreator I found that my test application would compile however because of other problems I still cannot move forward see [https://forum.qt.io/topic/162567/update-on-android-15-new-page-size-memory-16kb] for one the other is that qtcreator won't talk to my test phone: (android studio does talk to the the test phone but won't download the APK file because of the 4k/16k issue)
18:01:15: The deployment AVD "TestPhone" cannot be started.
18:01:15: Error while building/deploying project QtWeather (kit: Android QtAndroid Clang arm64-v8a)
18:01:15: When executing step "Deploy to Android device"Any help on ether would be good.
Thanks
-
Yes that seems to work:
/opt/android/sdk/platform-tools/adb install android-build-debug.apk
- daemon not running; starting now at tcp:5037
- daemon started successfully
Performing Streamed Install
Success
-
Yes that seems to work:
/opt/android/sdk/platform-tools/adb install android-build-debug.apk
- daemon not running; starting now at tcp:5037
- daemon started successfully
Performing Streamed Install
Success
I now have a new phone device in qtcreator and it gives me the option to use wifi for the connection.
The phone icon in the bottom left corner has a green blob on it with the identity SM-A065F(WIFI).The debug session progresses a way further now but stops with the following error:
E/AndroidRuntime: FATAL EXCEPTION: qtMainLoopThread
E/AndroidRuntime: Process: org.qtproject.example.QtTest, PID: 21601
E/AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "libssl_3.so" not found: needed by /data/app/~~p7huhxUk2n2nIc_1qxEgbQ==/org.qtproject.example.QtTest-rOiQXpwVmnydsevwxdlG2g==/base.apk!/lib/arm64-v8a/libQt6Network_arm64-v8a.so in namespace clns-4
E/AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:1090)
E/AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:1012)
E/AndroidRuntime: at java.lang.System.loadLibrary(System.java:1765)
E/AndroidRuntime: at org.qtproject.qt.android.QtLoader.loadLibraryHelper(QtLoader.java:478)
E/AndroidRuntime: at org.qtproject.qt.android.QtLoader.lambda$loadLibraries$1$org-qtproject-qt-android-QtLoader(QtLoader.java:554)
E/AndroidRuntime: at org.qtproject.qt.android.QtLoader$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
E/AndroidRuntime: at org.qtproject.qt.android.QtThread.lambda$run$0(QtThread.java:57)
E/AndroidRuntime: at org.qtproject.qt.android.QtThread$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
E/AndroidRuntime: at org.qtproject.qt.android.QtThread$1.run(QtThread.java:25)
E/AndroidRuntime: at java.lang.Thread.run(Thread.java:1119)
I/Process : Sending signal. PID: 21601 SIG: 9Looks like I need to copy the ssl libraries to a place where they can be included in the project apk file.
-
I now have a new phone device in qtcreator and it gives me the option to use wifi for the connection.
The phone icon in the bottom left corner has a green blob on it with the identity SM-A065F(WIFI).The debug session progresses a way further now but stops with the following error:
E/AndroidRuntime: FATAL EXCEPTION: qtMainLoopThread
E/AndroidRuntime: Process: org.qtproject.example.QtTest, PID: 21601
E/AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: library "libssl_3.so" not found: needed by /data/app/~~p7huhxUk2n2nIc_1qxEgbQ==/org.qtproject.example.QtTest-rOiQXpwVmnydsevwxdlG2g==/base.apk!/lib/arm64-v8a/libQt6Network_arm64-v8a.so in namespace clns-4
E/AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:1090)
E/AndroidRuntime: at java.lang.Runtime.loadLibrary0(Runtime.java:1012)
E/AndroidRuntime: at java.lang.System.loadLibrary(System.java:1765)
E/AndroidRuntime: at org.qtproject.qt.android.QtLoader.loadLibraryHelper(QtLoader.java:478)
E/AndroidRuntime: at org.qtproject.qt.android.QtLoader.lambda$loadLibraries$1$org-qtproject-qt-android-QtLoader(QtLoader.java:554)
E/AndroidRuntime: at org.qtproject.qt.android.QtLoader$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
E/AndroidRuntime: at org.qtproject.qt.android.QtThread.lambda$run$0(QtThread.java:57)
E/AndroidRuntime: at org.qtproject.qt.android.QtThread$$ExternalSyntheticLambda0.run(D8$$SyntheticClass:0)
E/AndroidRuntime: at org.qtproject.qt.android.QtThread$1.run(QtThread.java:25)
E/AndroidRuntime: at java.lang.Thread.run(Thread.java:1119)
I/Process : Sending signal. PID: 21601 SIG: 9Looks like I need to copy the ssl libraries to a place where they can be included in the project apk file.
The ssl libraries are now in the /opt/qt-android/lib directory and the build, deploy and debug session progresses until:
0:23:29: The command "/opt/android/sdk/platform-tools/adb -s 192.168.0.50:5555 pull /system/bin/app_process64 /work/Qt-Android/QtTest-V1.1.5c/application/build/Android_QtAndroid_Clang_arm64_v8a-Debug/android-app-process/app_process" terminated with exit code 1.
10:23:29: Package deploy: Failed to pull "/system/bin/app_process64" to "/work/Qt-Android/QtTest-V1.1.5c/application/build/Android_QtAndroid_Clang_arm64_v8a-Debug/android-app-process/app_process".Looks like I am missing a component of some sort but I don't know what, suggestions welcome.
thanks
-
in the main put qputenv("QT_DEBUG_PLUGINS", QByteArray("1")); it shows the logs of plugins
int main(int argc, char *argv[]) { qputenv("QT_DEBUG_PLUGINS", QByteArray("1")); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; .... }
@piervalli said in Testing Android APK with QtCreator fails with an error.:
qputenv("QT_DEBUG_PLUGINS", QByteArray("1"));
I added that call but no difference. I have a break point set on that line of code (it is the first executable line in my program) and it is not being reached.
I have checked that the Java is linking against my main (renaming it caused the build to fail with a missing symbol error).
When I start the debugger the phone shows a white screen with an android symbol on it and a message about waiting for the debugger it then closes after a few seconds.
The same symbol is present on my phones desktop which when clicked shows the white screen and android symbol briefly, sometimes there is a message about there being a bug in the app, -
the variable QT_DEBUG_PLUGINS shows logs when Qt loads the libraries, it is useful app crash on startup. To checks it you should checks the log ex. adb logcat findstr "Qt" or similar
A lot of data to look at, here are the last few lines that reference QtTest (edited to get passed spam filter), I could not see anything obviously when looking at the log overall.
qt.core.plugin.factoryloader: looking at "libplugins_platforms_qtforandroid_arm64-v8a.so"
qt.core.plugin.loader: Found metadata in lib /data/app/~~XIK_3oK5DKj4Pv2epcGJwQ==/org.qtproject.example.QtTest-z9izm4KcYpYvGHTt3ypwhw==/base.apk!/lib/arm64-v8a/libplugins_platforms_qtforandroid_arm64-v8a.so, metadata=
qt.core.library: "/data/app/~~XIK_3oK5DKj4Pv2epcGJwQ==/org.qtproject.example.QtTest-z9izm4KcYpYvGHTt3ypwhw==/base.apk!/lib/arm64-v8a/libplugins_platforms_qtforandroid_arm64-v8a.so" loaded library
qt.core.plugin.factoryloader: looking at "libplugins_styles_qandroidstyle_arm64-v8a.so"
qt.core.plugin.loader: Found metadata in lib /data/app/~~XIK_3oK5DKj4Pv2epcGJwQ==/org.qtproject.example.QtTest-z9izm4KcYpYvGHTt3ypwhw==/base.apk!/lib/arm64-v8a/libplugins_styles_qandroidstyle_arm64-v8a.so, metadata=
qt.core.plugin.factoryloader: looking at "libplugins_sqldrivers_qsqlite_arm64-v8a.so"
qt.core.plugin.loader: Found metadata in lib /data/app/~~XIK_3oK5DKj4Pv2epcGJwQ==/org.qtproject.example.QtTest-z9izm4KcYpYvGHTt3ypwhw==/base.apk!/lib/arm64-v8a/libplugins_sqldrivers_qsqlite_arm64-v8a.so, metadata=
qt.core.library: "/data/app/~~XIK_3oK5DKj4Pv2epcGJwQ==/org.qtproject.example.QtTest-z9izm4KcYpYvGHTt3ypwhw==/base.apk!/lib/arm64-v8a/libplugins_platforms_qtforandroid_arm64-v8a.so" unloaded library -
A lot of data to look at, here are the last few lines that reference QtTest (edited to get passed spam filter), I could not see anything obviously when looking at the log overall.
qt.core.plugin.factoryloader: looking at "libplugins_platforms_qtforandroid_arm64-v8a.so"
qt.core.plugin.loader: Found metadata in lib /data/app/~~XIK_3oK5DKj4Pv2epcGJwQ==/org.qtproject.example.QtTest-z9izm4KcYpYvGHTt3ypwhw==/base.apk!/lib/arm64-v8a/libplugins_platforms_qtforandroid_arm64-v8a.so, metadata=
qt.core.library: "/data/app/~~XIK_3oK5DKj4Pv2epcGJwQ==/org.qtproject.example.QtTest-z9izm4KcYpYvGHTt3ypwhw==/base.apk!/lib/arm64-v8a/libplugins_platforms_qtforandroid_arm64-v8a.so" loaded library
qt.core.plugin.factoryloader: looking at "libplugins_styles_qandroidstyle_arm64-v8a.so"
qt.core.plugin.loader: Found metadata in lib /data/app/~~XIK_3oK5DKj4Pv2epcGJwQ==/org.qtproject.example.QtTest-z9izm4KcYpYvGHTt3ypwhw==/base.apk!/lib/arm64-v8a/libplugins_styles_qandroidstyle_arm64-v8a.so, metadata=
qt.core.plugin.factoryloader: looking at "libplugins_sqldrivers_qsqlite_arm64-v8a.so"
qt.core.plugin.loader: Found metadata in lib /data/app/~~XIK_3oK5DKj4Pv2epcGJwQ==/org.qtproject.example.QtTest-z9izm4KcYpYvGHTt3ypwhw==/base.apk!/lib/arm64-v8a/libplugins_sqldrivers_qsqlite_arm64-v8a.so, metadata=
qt.core.library: "/data/app/~~XIK_3oK5DKj4Pv2epcGJwQ==/org.qtproject.example.QtTest-z9izm4KcYpYvGHTt3ypwhw==/base.apk!/lib/arm64-v8a/libplugins_platforms_qtforandroid_arm64-v8a.so" unloaded libraryThis is the entry for the main QtTest library:
nativeloader: Load /data/app/~~XIK_3oK5DKj4Pv2epcGJwQ==/org.qtproject.example.QtTest-z9izm4KcYpYvGHTt3ypwhw==/base.apk!/lib/arm64-v8a/libQtTest_arm64-v8a.so using class loader ns clns-4 (caller=/data/app/~~XIK_3oK5DKj4Pv2epcGJwQ==/org.qtproject.example.QtTest-z9izm4KcYpYvGHTt3ypwhw==/base.apk): ok
-
This is the entry for the main QtTest library:
nativeloader: Load /data/app/~~XIK_3oK5DKj4Pv2epcGJwQ==/org.qtproject.example.QtTest-z9izm4KcYpYvGHTt3ypwhw==/base.apk!/lib/arm64-v8a/libQtTest_arm64-v8a.so using class loader ns clns-4 (caller=/data/app/~~XIK_3oK5DKj4Pv2epcGJwQ==/org.qtproject.example.QtTest-z9izm4KcYpYvGHTt3ypwhw==/base.apk): ok
Running the adb command that is reported as failing outside of qtcreator reports what seems to be a permissions problem:
adb -s 192.168.0.50:42175 pull /system/bin/app_process64 /work/Qt-Android/QtTest-V1.1.5c/application/build/Android_QtAndroid_Clang_arm64_v8a-Debug/android-app-process/app_process
adb: error: failed to copy '/system/bin/app_process64' to '/work/Qt-Android/QtTest-V1.1.5c/application/build/Android_QtAndroid_Clang_arm64_v8a-Debug/android-app-process/app_process': remote open failed: Operation not permitted -
Running the adb command that is reported as failing outside of qtcreator reports what seems to be a permissions problem:
adb -s 192.168.0.50:42175 pull /system/bin/app_process64 /work/Qt-Android/QtTest-V1.1.5c/application/build/Android_QtAndroid_Clang_arm64_v8a-Debug/android-app-process/app_process
adb: error: failed to copy '/system/bin/app_process64' to '/work/Qt-Android/QtTest-V1.1.5c/application/build/Android_QtAndroid_Clang_arm64_v8a-Debug/android-app-process/app_process': remote open failed: Operation not permittedI don't know is it is relevant but if I try a Android Virtual Device (AVD) instead of a usb or wifi connected phone I get the following error:
The deployment AVD "TestPhone" cannot be started.
My thinking is if I deploy to a virtual phone device I might get a better perspective on my problem deploying to a real phone.
Can the TestPhone AVD be started outside of QtCreator to test it ?
The Icon shows a yellow blob while on the real phone (usb and WiFi) the blob on the icon is green.
-
I don't know is it is relevant but if I try a Android Virtual Device (AVD) instead of a usb or wifi connected phone I get the following error:
The deployment AVD "TestPhone" cannot be started.
My thinking is if I deploy to a virtual phone device I might get a better perspective on my problem deploying to a real phone.
Can the TestPhone AVD be started outside of QtCreator to test it ?
The Icon shows a yellow blob while on the real phone (usb and WiFi) the blob on the icon is green.
@SMF-Qt said in Testing Android APK with QtCreator fails with an error.:
Can the TestPhone AVD be started outside of QtCreator to test it ?
Yes, either from command line or from Android Studio.
See https://developer.android.com/studio/run/emulator-commandline?hl=en