How to set icon for Qt Android app in CMake?
-
Check the xml file in the build folder to see if it has changed. If not, delete the build folder and start anew.
wrote on 29 Oct 2022, 21:20 last edited by@SGaist I checked "AndroidManifest.xml" file in the build folder, it is not changed. "AndroidManifest.xml" file in the build folder will update everytime when we building. So if i modified the file, it will not reflect in the build apk.
-
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.
-
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.
-
Did you already do what is described here ?
-
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.
-
@Akshai also, delete the app from your device, let it install fresh
-
wrote on 6 Nov 2022, 17:20 last edited by Fest 11 Jun 2022, 19:15
I have exactly same problem. Can't set icon and force portrait mode.
AndroidManifest.xml from android directory and from build directory not same.Qt 6.4, QtCreator 8.0.2
-
wrote on 11 Nov 2022, 15:15 last edited by
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.
-
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!
wrote on 11 Nov 2022, 21:49 last edited by Fest 11 Dec 2022, 06:50@TomZ Thank you !
Adding this solved the issue ! Now everything works like a charm.if (ANDROID) set_target_properties(${PROJECT_NAME} PROPERTIES QT_ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/android ) qt6_android_generate_deployment_settings(${PROJECT_NAME}) qt_android_add_apk_target(${PROJECT_NAME}) endif ()
- I use QT_ANDROID_PACKAGE_SOURCE_DIR instead.