Testing Android APK with QtCreator fails with an error.
-
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 -
@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=enWell looks like the idea of using a virtual phone in this case is a non starter:
root [ ~ ]# /opt/android/sdk/emulator/emulator -avd TestPhone
INFO | Android emulator version 35.6.11.0 (build_id 13610412) (CL:N/A)
INFO | Graphics backend: gfxstream
INFO | Found systemPath /opt/android/sdk/system-images/android-28/google_apis/arm64-v8a/
PANIC: Avd's CPU Architecture 'arm64' is not supported by the QEMU2 emulator on x86_64 host. -
Well looks like the idea of using a virtual phone in this case is a non starter:
root [ ~ ]# /opt/android/sdk/emulator/emulator -avd TestPhone
INFO | Android emulator version 35.6.11.0 (build_id 13610412) (CL:N/A)
INFO | Graphics backend: gfxstream
INFO | Found systemPath /opt/android/sdk/system-images/android-28/google_apis/arm64-v8a/
PANIC: Avd's CPU Architecture 'arm64' is not supported by the QEMU2 emulator on x86_64 host.@SMF-Qt said in Testing Android APK with QtCreator fails with an error.:
PANIC: Avd's CPU Architecture 'arm64' is not supported by the QEMU2 emulator on x86_64 host.
Create a x86_64 virtual device and deploy a x86_64 build of your app
-
@SMF-Qt said in Testing Android APK with QtCreator fails with an error.:
PANIC: Avd's CPU Architecture 'arm64' is not supported by the QEMU2 emulator on x86_64 host.
Create a x86_64 virtual device and deploy a x86_64 build of your app
I could but I think this is a build issue, I think I need to find out more about this "app_process" file that is missing.
I ran strace on qtcreator and re-built the app and the only reference to "app_process" is a test for its existance which failed:access("/work/Qt-Android/QtTest-V1.1.5c/application/build/Android_QtAndroid_Clang_arm64_v8a-Debug/android-app-process/app_process", F_OK) = -1 ENOENT (No such file or directory)
-
I could but I think this is a build issue, I think I need to find out more about this "app_process" file that is missing.
I ran strace on qtcreator and re-built the app and the only reference to "app_process" is a test for its existance which failed:access("/work/Qt-Android/QtTest-V1.1.5c/application/build/Android_QtAndroid_Clang_arm64_v8a-Debug/android-app-process/app_process", F_OK) = -1 ENOENT (No such file or directory)
According to Googles AI:
-
What is app_process?
app_process is a binary found in the /system/bin directory on Android devices. According to Stack Overflow, it's a device binary created by the full device build.
It's the entry point for starting a Java process within the Android runtime environment.
It's used to run applications, often those that need to interact with system-level services or bypass normal Android application lifecycle restrictions.
It can be used to execute JAR files or DEX files within a Dalvik/ART environment.
Essentially, it's how you can run custom Java code as a separate process on an Android device, outside the typical app sandbox. -
-
According to Googles AI:
-
What is app_process?
app_process is a binary found in the /system/bin directory on Android devices. According to Stack Overflow, it's a device binary created by the full device build.
It's the entry point for starting a Java process within the Android runtime environment.
It's used to run applications, often those that need to interact with system-level services or bypass normal Android application lifecycle restrictions.
It can be used to execute JAR files or DEX files within a Dalvik/ART environment.
Essentially, it's how you can run custom Java code as a separate process on an Android device, outside the typical app sandbox. -
-
So if I understand what adb and google are telling me the issue is that the operating system on my test phone is blocking adb's access to /system/bin/.
I wonder if this is a Samsung thing the test phone is a Samsung A06 ?
Using adb shell I have found the adbd server on my test phone:
shell 26668 1 0 40:23 ? 00:04:49 adbd --root_seclabel=u:r:su:s0 --tim_seclabel=u:r:adbd_tradeinmode:s0
It is running as user shell which I think does not have read access to /system/bin.
So I think my next step is to root the Test Phone and see if that helps.
-
The
adb: error: failed to copy '/system/bin/app_process64'
is something new with Android 15.I have started seeing this issue with my Samsung Galaxy S23 with Android 15.
See this other report at https://forum.qt.io/topic/162537/qt-creator-android-15-adb.exe-pull-system-bin-app_process64-error
In my case native debugging with Android Studio doesn't work with the Galaxy S23. It does work with the Arm64 Emulator with Android 15.
I tested with a Samsung Galaxy S10e with Android 12, and everything worked fine with Qt Creator 17...
-
The
adb: error: failed to copy '/system/bin/app_process64'
is something new with Android 15.I have started seeing this issue with my Samsung Galaxy S23 with Android 15.
See this other report at https://forum.qt.io/topic/162537/qt-creator-android-15-adb.exe-pull-system-bin-app_process64-error
In my case native debugging with Android Studio doesn't work with the Galaxy S23. It does work with the Arm64 Emulator with Android 15.
I tested with a Samsung Galaxy S10e with Android 12, and everything worked fine with Qt Creator 17...
Thanks for the info, the Samsung A06 I am currently using has Android 14 currently installed.
-
Thanks for the info, the Samsung A06 I am currently using has Android 14 currently installed.
I did not make any progress rooting my Test Phone (Samsung A06), however I tried an old HTC M9 running Android 7.0 and that did proceed past the adb pull request for "app_process" but failed because the APK package is too new for Android 7.0 (expected failure).
-
I did not make any progress rooting my Test Phone (Samsung A06), however I tried an old HTC M9 running Android 7.0 and that did proceed past the adb pull request for "app_process" but failed because the APK package is too new for Android 7.0 (expected failure).
@SMF-Qt said in Testing Android APK with QtCreator fails with an error.:
I did not make any progress rooting my Test Phone (Samsung A06), however I tried an old HTC M9 running Android 7.0 and that did proceed past the adb pull request for "app_process" but failed because the APK package is too new for Android 7.0 (expected failure).
Android 9 is the minimum required for Qt for Android 6.9.
According to Wikipedia you can get Android 11 for HTC One M9. The steps to do this unofficial upgrade are listed here. I have no idea how this would work.
-
I think for now I am going to put arm64-v8a activities on hold as both hardware and emulated deployments have issues and try jsulm's suggestion of an X86_64 setup. I have already tested the X86_64 phone simulator outside of both qtcreator and Android Studio and it appears to function ok.
-
I think for now I am going to put arm64-v8a activities on hold as both hardware and emulated deployments have issues and try jsulm's suggestion of an X86_64 setup. I have already tested the X86_64 phone simulator outside of both qtcreator and Android Studio and it appears to function ok.
Ok thanks for the suggestions I now have a working X86_64 emulator and an X86_64 apk build that deploys to the emulated phone.
My next problem is that the deployed app crashes on startup, but to investigate that I think I will start a new thread and come back to the arm64-v8a problems when my test application is more usable.
...
Installing Android package to device.
Running command "/opt/android/sdk/platform-tools/adb -s emulator-5554 install -r /work/Qt-Android/QtTest/application/build/Android_Qt_6_9_1_qt_androidX86_Clang_x86_64-Debug/android-build//build/outputs/apk/debug/android-build-debug.apk"
Performing Streamed Install
Success
Android package built successfully in 0.572 ms.
-- It can now be run from the selected device/emulator.
-- File: /work/Qt-Android/QtTest/application/build/Android_Qt_6_9_1_qt_androidX86_Clang_x86_64-Debug/android-build//build/outputs/apk/debug/android-build-debug.apk
14:18:06: The process "/opt/qt6/bin/androiddeployqt" exited normally.
14:18:06: Package deploy: Running command "/opt/android/sdk/platform-tools/adb -s emulator-5554 pull /system/bin/app_process64 /work/Qt-Android/QtTest/application/build/Android_Qt_6_9_1_qt_androidX86_Clang_x86_64-Debug/android-app-process/app_process".
14:18:06: Package deploy: Running command "/opt/android/sdk/platform-tools/adb -s emulator-5554 pull /system/bin/linker64 /work/Qt-Android/QtTest/application/build/Android_Qt_6_9_1_qt_androidX86_Clang_x86_64-Debug/android-app-process/linker64".
14:18:06: Package deploy: Running command "/opt/android/sdk/platform-tools/adb -s emulator-5554 pull /system/lib64/libc.so /work/Qt-Android/QtTest/application/build/Android_Qt_6_9_1_qt_androidX86_Clang_x86_64-Debug/android-app-process/libc.so".
14:18:06: Elapsed time: 00:05. -
S SMF-Qt referenced this topic