Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-138192

Android Templates, Manifest and CMake Properties

    XMLWordPrintable

Details

    • Android
    • 2025wk34s2QtforAndroid

    Description

      Thx for all your work to make my life as a Qt Android App Developer easier with CMake.
      see also: 
      QTBUG-106907 ("package" deprecated)
      https://www.qt.io/blog/qt-6.9-android-updates (assam)

      Want to blog about all the new possibilities, but there are some questions: 

      Create new Qt Quick Project
      To test the defaults and HowTo adapt the changes in Android Manifest, I created a new Qt Quick Project named 'test_manifest' and selected Qt 6.9.1 Android, macOS, iOS as Kits.
      Create Templates
      Then I tapped on 'Create Templates' to copy Manifest and Gradle etc into my project /android
      At the end I got a Dialog 'Project File could not be updated' - I really don't know what's not updated - the Manifest and Gradle files are all there. 
      In CMakeLists.txt, in 

      qt_add_qml_module(apptest_manifest...

       all the copied files were added as RESOURCES:

      RESOURCES android/AndroidManifest.xml android/build.gradle android/res/values/libs.xml android/res/xml/qtprovider_paths.xml android/gradle/wrapper/gradle-wrapper.jar android/gradle/wrapper/gradle-wrapper.properties android/gradle.properties android/gradlew android/gradlew.bat

      AFAIK this is wrong ! Setting QT_ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/android is all needed.

      QT_ANDROID_PACKAGE_NAME (since Qt 6.8)
      The generated Manifest still contains 'org.qtproject.example' as package name and displays this in 'General' Tab. Simply removing the package name gives a warning 'The Package Name is not valid'. From QT_ANDROID_PACKAGE_NAME docs I know, that the property must be removed completely, so I removed 

      package="org.qtproject.example" 

      from 'XML Source' Tab. Now I could compile the project without a package name in Manifest
      Because I added nothing to CMakeLists.txt yet, Qt uses as default package 'org.qtproject.example.apptest_manifest' - sounds good.

      Generating Templates from Qt 6.9.1 should generate a Manifest file without the package property and 'General' Tab should display 'Not Set' similar to Min and Target SDK which are also removed from Manifest since some time.
      There's another problem: When package name property was removed and you switch between 'General' and 'XML Source' Tab, by magic the Manifest Editor added

      package=""

      under the hood.

      workaround: before saving changes always go to 'XML Source' Tab, remove 

      package=""

      then save.

      QT_ANDROID_APP_NAME (since Qt 6.9)
      The generated Manifest contains 

      <application ... android:label="-- %%INSERT_APP_NAME%% --" ... /application>

      this is OK.
      Unfortunately the <activity label was empty: "", so the app running on Android Device has no Title Label.
      Would be better, also to set 

      <activity ... android:label="-- %%INSERT_APP_NAME%% --" ... /activity>

      As long as nothing set in CMakeLists.txt, Qt uses as default the projects target name, in my case 'apptest_manifest'

      QT_ANDROID_APP_ICON (since Qt 6.9)
      the generated Manifest doesn't contain the 'android:icon property'.
      Thought, it's because there are no icons yet. So I copied Icons into the project - in my case under 

      /android/res

       I have now 'drawable' folders containing icon.png. By magic, QtCreator added this property: 

      android:icon="@drawable/icon"

      When generating Manifest for 6.9.1, there should always be a generated 

      android:icon="-- %%INSERT_APP_ICON%% --"

       

      QMAKE ??
      Will QT_ANDROID_PACKAGE_NAME, QT_ANDROID_APP_NAME, QT_ANDROID_APP_ICON also be supported by QMake ?
      Porting all my customers apps from QMake to CMake will take some more months, so would be cool.

      style (since 6.7 obsolete)
      The docs are wrong, should mention that style is obsolete since 6.7: 
      https://doc.qt.io/qt-6/android-manifest-file-configuration.html#style-extraction
      Also Manifest 'General' Tab should set style to 'not set' or so, ATM style is set to 'Default' on 'General' Tab

      qt_add_android_permission (since Qt 6.9)
      So cool that in the meantime 'never for location' is default for module-generated BT permissions. QTBUG-117358
      also great to be able to add permissions with attributes in CMakeLists.txt using qt_add_android_permission()
      what if I add one permission - per ex 'BLUETOOTH_SCAN' using qt_add_android_permission, while

      <!-- %%INSERT_PERMISSIONS -->

      is still in Manifest. Does this mean from the Bluetooth module now only the 'BLUETOOTH_SCAN' will be used and from other modules all auto-generated will remain ? 

      My Target properties
      Finally these are the target properties I set:

      set_target_properties(apptest_manifest
          PROPERTIES
          QT_ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/android
          QT_ANDROID_MIN_SDK_VERSION "28"
          QT_ANDROID_TARGET_SDK_VERSION "35"
          QT_ANDROID_PACKAGE_NAME "org.ekkescorner.test.manifest"
          QT_ANDROID_APP_ICON "@drawable/icon"
          QT_ANDROID_APP_NAME "Test Manifest"
      )

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              qtandroidteam Qt Android Team
              ekkescorner Ekkehard
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes