androidqt-creatorqt6

Qt 6.9.0, how to deploy Android apk signed automatically for debugging?


I'm migrating from Qt 6.2.2 (QtCreator 6.0.2) to Qt 6.9.0 (QtCreator 16.0.0).

With Qt 6.2.2, I could simply compile and deploy an apk on an Android device. The project's properties has a "Build Android APK"/"Application signature", but I never used it and everything works fine.

With Qt 6.9.0, I'm getting the error:

adb: failed to install C:/Users/XXXXXXX/Documents/QtExample/camera/build/Android_Qt_6_9_0_Clang_armeabi_v7a-Release/android-build//build/outputs/apk/release/android-build-release-unsigned.apk: Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES: Failed to collect certificates from /data/app/vmdl639520454.tmp/base.apk: Attempt to get length of null array]
Installing to device failed!
Installing Android package to device.
Running command "C:/Android/rXX_Qt_690/android_sdk/platform-tools/adb.exe -s ffbd8cb2  install -r C:/Users/XXXXXXX/Documents/QtExample/camera/build/Android_Qt_6_9_0_Clang_armeabi_v7a-Release/android-build//build/outputs/apk/release/android-build-release-unsigned.apk"
Performing Streamed Install
17:10:36: The process "C:\Qt\6.9.0\mingw_64\bin\androiddeployqt.exe" exited with code 16.

I'm deploying on the same device, so it's definitely accepting unsigned apk (or at least apk I did not explicitely requested to sign, but it was signed silently by androiddeployqt) to be deployed and executed.

If I go to the project properties "Build Android APK"/"Application signature", create a keystore, check "Sign package", then it works (I see in the log that androiddeployqt is invoked twice with --sign parameter set). But then I need to do this everytime I re-open the project in QtCreator (only keystore location is persistent, "Sign package" is not, so I need to go and check it manually after the project is opened and I also need to enter keystore password), doing this during development is annoying. I'd really like to avoid that.

How can I:


Note, I tried to set ANDROID_DEPLOYMENT_SETTINGS_FILE .pro variable to a custom json file with the following bloc:

"signing": {
    "store": "C:/Users/me/.android/debug.keystore",
    "storePassword": "android",
    "keyAlias": "androiddebugkey",
    "keyPassword": "android"
}

The custom .json is used, I see it in the log, but I'm strill getting the same error in the end


Solution

  • After fighting with this for some days, asked chatgpt if there was a way to customize androiddeployqt arguments from my .pro file (to add the --sign parameters silently)...found no way to do this with Qt 6.9.0.

    Checked qtcreator code from github: there is no way to override either the path to androiddeployqt or its arguments as it was likelly in earlier version

    So, finally, I renamed `androidqtdeploy.exe` as `androidqtdeploy_original.exe` and created my own `androidqtdeploy.exe` that adds the appropriate `--sign` parameters and calls `androidqtdeploy_original.exe`.

    This works fine! I can now deploy apk without checking the "Sign package" option.