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

androiddeployqt requires a manifest 'package' attribute, which is deprecated in Gradle 7.x

    XMLWordPrintable

Details

    • Android

    Description

      I'm in the process of upgrading the Gradle version in our Qt Android project from Gradle 4.1.0 to 7.4.1. This newer version of Gradle deprecates the use of a 'package' attribute in the 'manifest' element of the AndroidManifest.xml file. We have this in our AndroidManifest.xml file:

      <?xml version="1.0" encoding="utf-8"?>
      <manifest
        package="com.trimble.access"
        ...etc> 

      When I build the project, Gradle reports a warning about 'package' being deprecated:

      package="com.trimble.access" found in source AndroidManifest.xml: C:\dev\access\Survey\Android-ARM64-Release\android-build\AndroidManifest.xml.
      Setting the namespace via a source AndroidManifest.xml's package attribute is deprecated.
      Please instead set the namespace (or testNamespace) in the module's build.gradle file, as described here: https://developer.android.com/studio/build/configure-app-module#set-namespace 

      I tried doing exactly what this warning suggested - removing the 'package' attribute from the manifest, and adding a 'namespace' setting in the build.gradle file:

      android {
          namespace = "com.trimble.access"
          ...etc
      }

      But now the build fails entirely, as androiddeployqt reports a fatal error:

      Invalid android manifest file: C:/dev/Android-ARM64-Release/android-build/AndroidManifest.xml

      I found the source code for androiddeployqt on code.qt.io, and it's clear that it's going to unconditionally fail with this error if the 'package' attribute is not present:

          if (!reader.attributes().hasAttribute("package"_L1)) {
              fprintf(stderr, "Invalid android manifest file: %s\n", qPrintable(androidManifestPath));
              return false;
          } 

      Now that the 'package' attribute is not only optional, but deprecated, this check no longer makes sense.

      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
              roballan Rob Allan
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes