How to set icon for Qt Android app in CMake?
-
@SGaist Please see steps below.
- Created Qt android project in CMake and build in release mode.
- Created a folder named "android" in project folder (Where CMakeLists.txt file exist)
- Copied "AndroidManifest.xml" from "android-build" folder and paste it to "android" folder which already created in step 2.
- Open Projects option Qt , and under "Build Android APK" option selected "Create Templates" and edited "AndroidManifest.xml" (Added icon)
- Build again and deployed. The icon not updated.!
Please see my edited "AndroidManifest.xml" file below.
Capture.PNG -
Check the xml file in the build folder to see if it has changed. If not, delete the build folder and start anew.
-
-
It's not that one that you have to change. It's the one you copied into your sources. It should then be used when building your application.
-
Which version of Qt are you using ?
-
That's Qt Creator. I am asking which version you use to build your application.
-
So you put your Androïd related changes in the else clause that concerns Qt 5.
-
Move your changes to the Qt 6 part of the if.
-
Remember to do a full rebuild (clean, run cmake, rebuild) when you change cmake code.
-
I just yesterday figured this out for my app.
- I use QT_ANDROID_PACKAGE_SOURCE_DIR instead.
See the full CMake snippet here;
set_target_properties(pay_mobile PROPERTIES QT_ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/android )
-
The XML file is in my subdir 'android' (as the above shows). It includes the property
android:icon="@drawable/icon"
Example here. -
In that same 'android' directory there is a `res/drawable' set of directories which contain the icons with the 'icon' base for the filename. Both of those you can see reflected in the above point. link.
Hope that helps!
- I use QT_ANDROID_PACKAGE_SOURCE_DIR instead.