I'm building my Qt/C++ Android application in Release build, however the following APK files are produced:
Release/android-build/bin/QtApp-debug.apk
Release/android-build/bin/QtApp-debug-unaligned.apk
I found this question which implies that the APK files are built in debug mode even for Release builds. The answers there imply that Release builds are possible only if you have a Certificate.
I followed the instructions there, and indeed after creating a Certificate, I get these files instead:
Release/android-build/bin/QtApp-release.apk
Release/android-build/bin/QtApp-release-unsigned.apk
Why do I need a Certificate to create a Release APK, and if there is no Certificate, is there a difference between Release build and Debug build, or do they both contain unoptimized code?
Edit: In light of the posted answer, I'd like to clarify that I'm asking why does not having a certificate necessitate for Qt Creator to compile C++ code with optimizations switched off and debug info added?
Major differences are the debug apk and the release apk: For debug builds the apk will be signed with the default debug signing keys with debug flag enabled. For release apk you will have to explicitly specify the apk to sign with and the debug flag will be turned off so that it cannot be debugged.
Open your project with Qt Creator 4.11 or later choosing a Release Build . Select Projects > Build > Build Android APK > Create Templates to create the Android package template files such as AndroidManifest. xml which is the main file of concern here.
This seems to be a bug on the build process of Qt Creator. The C++ files are compiled as they should, according to the selected build configuration (with optimizations and no debug info on release mode). So no matter your APK is named QtApp-debug.apk, the binaries inside are compiled as you choose.
The problem comes when calling androiddeployqt
. If you look at the source, it creates a release package if it receives --release
or also when it receives --sign
. Qt Creator never passes the --release
, so it compiles files as it should, but androiddeployqt
only generates a release APK when you use a certificate, because Qt Creator passes the --sign
What are the differences of androiddeployqt creating a debug package:
gdbserver
binary (aprox 250 KB on arm-v7) ant
with 'debug' instead of 'release'. This is what makes your apk signed with a debug keyNot having a certificate is not turning off optimizations and adding debug info, it's just creating a debug package, with debug signature which is necessary if you don't add your own. So after all, maybe it's not a bug.
It may be an old question, but I have witnessed the same problem with Qt 5.12.3, a Release
build produced debug APK in Release
directory.
This happened because I didn't check on 'Signed' checkbox (and if you check it, you will be asked for password) when starting QtCreator. After providing password I got the usual android-build-release-signed.apk
file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With