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 10.6k Views 3 Watching
  • 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.
  • SGaistS SGaist

    Did you already do what is described here ?

    AkshaiA Offline
    AkshaiA Offline
    Akshai
    wrote on 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
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on 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

      AkshaiA 1 Reply Last reply
      0
      • SGaistS SGaist

        Which version of Qt are you using ?

        AkshaiA Offline
        AkshaiA Offline
        Akshai
        wrote on last edited by
        #13

        @SGaist Latest one.Capture.PNG

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on 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

          AkshaiA 1 Reply Last reply
          0
          • SGaistS SGaist

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

            AkshaiA Offline
            AkshaiA Offline
            Akshai
            wrote on last edited by
            #15

            @SGaist This one.aaa.png

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on 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

              AkshaiA 1 Reply Last reply
              0
              • SGaistS SGaist

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

                AkshaiA Offline
                AkshaiA Offline
                Akshai
                wrote on last edited by
                #17

                @SGaist What to do? please guide me.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 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

                  AkshaiA 1 Reply Last reply
                  0
                  • SGaistS SGaist

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

                    AkshaiA Offline
                    AkshaiA Offline
                    Akshai
                    wrote on 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
                    0
                    • sierdzioS Offline
                      sierdzioS Offline
                      sierdzio
                      Moderators
                      wrote on last edited by
                      #20

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

                      (Z(:^

                      AkshaiA 1 Reply Last reply
                      0
                      • AkshaiA Akshai

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

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

                          AkshaiA Offline
                          AkshaiA Offline
                          Akshai
                          wrote on 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 last edited by Fest
                            #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 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
                              2
                              • TomZT TomZ

                                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 last edited by Fest
                                #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
                                1
                                • AkshaiA Offline
                                  AkshaiA Offline
                                  Akshai
                                  wrote on last edited by Akshai
                                  #26

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

                                  Untitled.png

                                  1 Reply Last reply
                                  0
                                  • F Fest

                                    @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 Offline
                                    L Offline
                                    Luis Miguel
                                    wrote on last edited by
                                    #27

                                    @Fest I would honestly love to understand how you came up with that. I'm still too new to understand what's going on in CMakeLists.

                                    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