Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to set icon for Qt Android app in CMake?

How to set icon for Qt Android app in CMake?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
27 Posts 7 Posters 4.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S SGaist
    29 Oct 2022, 19:09

    Check the xml file in the build folder to see if it has changed. If not, delete the build folder and start anew.

    A Offline
    A Offline
    Akshai
    wrote on 29 Oct 2022, 21:20 last edited by
    #7

    @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.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 30 Oct 2022, 20:19 last edited by
      #8

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply 31 Oct 2022, 15:30
      0
      • S SGaist
        30 Oct 2022, 20:19

        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.

        A Offline
        A Offline
        Akshai
        wrote on 31 Oct 2022, 15:30 last edited by
        #9

        @SGaist I could not set the modified "AndroidManifest.xml" path which should be used when building your application. How can i set through "CMakeLists.txt" file?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 31 Oct 2022, 19:52 last edited by
          #10

          Did you already do what is described here ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          A 1 Reply Last reply 2 Nov 2022, 18:55
          0
          • S SGaist
            31 Oct 2022, 19:52

            Did you already do what is described here ?

            A Offline
            A Offline
            Akshai
            wrote on 2 Nov 2022, 18:55 last edited by
            #11

            @SGaist Yes i did it in the way. But no result. Please see my attached screenshot. Qt_Forum_Question_Details.png

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 2 Nov 2022, 19:38 last edited by
              #12

              Which version of Qt are you using ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              A 1 Reply Last reply 2 Nov 2022, 19:46
              0
              • S SGaist
                2 Nov 2022, 19:38

                Which version of Qt are you using ?

                A Offline
                A Offline
                Akshai
                wrote on 2 Nov 2022, 19:46 last edited by
                #13

                @SGaist Latest one.Capture.PNG

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 2 Nov 2022, 19:47 last edited by
                  #14

                  That's Qt Creator. I am asking which version you use to build your application.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  A 1 Reply Last reply 2 Nov 2022, 19:56
                  0
                  • S SGaist
                    2 Nov 2022, 19:47

                    That's Qt Creator. I am asking which version you use to build your application.

                    A Offline
                    A Offline
                    Akshai
                    wrote on 2 Nov 2022, 19:56 last edited by
                    #15

                    @SGaist This one.aaa.png

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on 2 Nov 2022, 19:59 last edited by
                      #16

                      So you put your Androïd related changes in the else clause that concerns Qt 5.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      A 1 Reply Last reply 2 Nov 2022, 20:22
                      0
                      • S SGaist
                        2 Nov 2022, 19:59

                        So you put your Androïd related changes in the else clause that concerns Qt 5.

                        A Offline
                        A Offline
                        Akshai
                        wrote on 2 Nov 2022, 20:22 last edited by
                        #17

                        @SGaist What to do? please guide me.

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on 2 Nov 2022, 20:27 last edited by
                          #18

                          Move your changes to the Qt 6 part of the if.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          A 1 Reply Last reply 2 Nov 2022, 20:36
                          0
                          • S SGaist
                            2 Nov 2022, 20:27

                            Move your changes to the Qt 6 part of the if.

                            A Offline
                            A Offline
                            Akshai
                            wrote on 2 Nov 2022, 20:36 last edited by
                            #19

                            @SGaist Done as mentioned. But there is no change found. Please see screenshot.aaa.png

                            J.HilkJ 1 Reply Last reply 3 Nov 2022, 10:09
                            0
                            • sierdzioS Offline
                              sierdzioS Offline
                              sierdzio
                              Moderators
                              wrote on 3 Nov 2022, 09:05 last edited by
                              #20

                              Remember to do a full rebuild (clean, run cmake, rebuild) when you change cmake code.

                              (Z(:^

                              A 1 Reply Last reply 4 Nov 2022, 18:44
                              0
                              • A Akshai
                                2 Nov 2022, 20:36

                                @SGaist Done as mentioned. But there is no change found. Please see screenshot.aaa.png

                                J.HilkJ Offline
                                J.HilkJ Offline
                                J.Hilk
                                Moderators
                                wrote on 3 Nov 2022, 10:09 last edited by
                                #21

                                @Akshai also, delete the app from your device, let it install fresh


                                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                                Q: What's that?
                                A: It's blue light.
                                Q: What does it do?
                                A: It turns blue.

                                1 Reply Last reply
                                0
                                • sierdzioS sierdzio
                                  3 Nov 2022, 09:05

                                  Remember to do a full rebuild (clean, run cmake, rebuild) when you change cmake code.

                                  A Offline
                                  A Offline
                                  Akshai
                                  wrote on 4 Nov 2022, 18:44 last edited by
                                  #22

                                  @sierdzio @J-Hilk I have done as you guys mentioned. Couldn't found any change.

                                  aaa.png

                                  1 Reply Last reply
                                  0
                                  • F Offline
                                    F Offline
                                    Fest
                                    wrote on 6 Nov 2022, 17:20 last edited by Fest 11 Jun 2022, 19:15
                                    #23

                                    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

                                    1 Reply Last reply
                                    0
                                    • TomZT Offline
                                      TomZT Offline
                                      TomZ
                                      wrote on 11 Nov 2022, 15:15 last edited by
                                      #24

                                      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!

                                      F 1 Reply Last reply 11 Nov 2022, 21:49
                                      2
                                      • TomZT TomZ
                                        11 Nov 2022, 15:15

                                        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!

                                        F Offline
                                        F Offline
                                        Fest
                                        wrote on 11 Nov 2022, 21:49 last edited by Fest 11 Dec 2022, 06:50
                                        #25

                                        @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 ()
                                        
                                        L 1 Reply Last reply 7 Jan 2025, 03:59
                                        1
                                        • A Offline
                                          A Offline
                                          Akshai
                                          wrote on 20 Nov 2022, 20:49 last edited by Akshai
                                          #26

                                          @TomZ Thank you !!!
                                          Added below line. This solved my issue.

                                          Untitled.png

                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved