Skip to content

[flutter_tools] Support namespace attribute introduced in AGP 7.3 #121404

@navaronbracke

Description

@navaronbracke

From AGP(android gradle plugin) 7.3 onwards it is recommended to replace the use of the package attribute in the Manifest.xml with the namespace attribute in the build.gradle file.

We should update the tooling to support this new attribute.

  1. Check the build.gradle for a namespace attribute
  2. If it is not found, fall back to checking the Manifest's package attribute

https://developer.android.com/guide/topics/manifest/manifest-element (see the last phrase under package)
https://developer.android.com/studio/build/configure-app-module#set-namespace

Steps to Reproduce

  1. flutter create myapp
  2. Remove the package attribute from the Android Manifest
  3. In android/app/build.gradle use the new namespace attribute:
android {
  namespace '<value of the original package attribute from the Manifest>'
}
  1. flutter run
  2. The app fails to build (see the logs below)

Logs

Logs
navaronbracke@MacBook-Pro-van-Navaron weforza % flutter run
Launching lib/main.dart on motorola one in debug mode...
package identifier or launch activity not found.
Please check /Users/navaronbracke/Documents/weforza/android/app/src/main/AndroidManifest.xml for errors.
No application found for TargetPlatform.android_arm64.
Is your project missing an android/app/src/main/AndroidManifest.xml?
Consider running "flutter create ." to create one.
[✓] Flutter (Channel stable, 3.7.3, on macOS 13.2 22D49 darwin-x64, locale en-BE)
    • Flutter version 3.7.3 on channel stable at /Users/navaronbracke/Documents/flutter
    • Upstream repository [email protected]:navaronbracke/flutter.git
    • FLUTTER_GIT_URL = [email protected]:navaronbracke/flutter.git
    • Framework revision 9944297138 (2 weeks ago), 2023-02-08 15:46:04 -0800
    • Engine revision 248290d6d5
    • Dart version 2.19.2
    • DevTools version 2.20.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/navaronbracke/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • ANDROID_HOME = /Users/navaronbracke/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] VS Code (version 1.75.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.58.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 13.2 22D49 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 110.0.5481.177

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityc: proposalA detailed proposal for a change to Flutterplatform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versiont: gradle"flutter build" and "flutter run" on AndroidtoolAffects the "flutter" command-line tool. See also t: labels.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions