New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[add-to-app] error : Namespace not specified. Please specify a namespace in the module's build.gradle #126403
Comments
This comment was marked as outdated.
This comment was marked as outdated.
It seems you are using AGP and Gradle version from 8.0 because I can see this issue when upgrading AGP to This issue is reproducible on the latest Sample code: namespace-gradle-issue flutter doctor -v (stable and master)[✓] Flutter (Channel stable, 3.7.12, on macOS 13.0.1 22A400 darwin-x64, locale en-VN)
• Flutter version 3.7.12 on channel stable at /Users/huynq/Documents/GitHub/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 4d9e56e694 (2 days ago), 2023-04-17 21:47:46 -0400
• Engine revision 1a65d409c7
• Dart version 2.19.6
• DevTools version 2.20.1
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
• Android SDK at /Users/huynq/Library/Android/sdk
• Platform android-33, build-tools 32.0.0
• ANDROID_HOME = /Users/huynq/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14E222b
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.1)
• 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.15+0-b2043.56-8887301)
[✓] IntelliJ IDEA Community Edition (version 2022.1.1)
• IntelliJ at /Users/huynq/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/221.5591.52/IntelliJ IDEA CE.app
• 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
[✓] VS Code (version 1.77.3)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.62.0
[✓] Connected device (3 available)
• SM T225 (mobile) • R9JT3004VRJ • android-arm64 • Android 13 (API 33)
• macOS (desktop) • macos • darwin-x64 • macOS 13.0.1 22A400 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 112.0.5615.137
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found! [!] Flutter (Channel master, 3.11.0-2.0.pre.73, on macOS 13.0.1 22A400 darwin-x64, locale en-VN)
• Flutter version 3.11.0-2.0.pre.73 on channel master at /Users/huynq/Documents/GitHub/flutter_master
! Warning: `flutter` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
! Warning: `dart` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 8c5a1ea728 (7 hours ago), 2023-05-08 14:00:20 -0700
• Engine revision 8d3a8162b3
• Dart version 3.1.0 (build 3.1.0-86.0.dev)
• DevTools version 2.23.1
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
• Android SDK at /Users/huynq/Library/Android/sdk
• Platform android-33, build-tools 32.0.0
• ANDROID_HOME = /Users/huynq/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14E222b
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2022.2)
• 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 17.0.6+0-17.0.6b802.4-9586694)
[✓] VS Code (version 1.78.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.62.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-x64 • macOS 13.0.1 22A400 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 112.0.5615.137
[✓] Network resources
• All expected network resources are available.
! Doctor found issues in 1 category. |
Nope, that will only fix plugins. I'm not familiar with the internals of the Android add-to-app, but I expect the namespace needs to be added to one or more of:
|
With master checked out I was able to run
And the apk successfully built. Next I will try on stable. |
Using the tag 3.10.0-15.0.pre which I think is the latest stable I see the same behavior as master.
|
You'd need to add the module to a non-Flutter-template app that's using AGP 8.0, if I'm understanding the issue correctly. |
Other things that probably should be fixed at the same time.
|
🤦 there is an example. I will work off that |
To reproudce failure
|
Additional steps discovered Modify settings.gradle to include the path to your own dependencies (follow output from flutter build arr) |
Handing over to @camsim99 to keep this moving forward. |
I was able to reproduce the issue and thanks to the reproduction example above and @reidbaker's suggestion to try the AGP upgrade assistant in Android Studio. I can confirm we need to add namespace to all of the I believe I'll need to update the following:
I'll work on verifying this and submitting a PR for the fix. I also will find a good place to add a note on the website in case folks run into this issue if anyone knows a good page offhand! |
Verified that modifying those works, so submitting PRs. |
Adds `namespace` to module `build.gradle` file templates. Fixes #126403.
…6963) Adds `namespace` to module `build.gradle` file templates. Fixes flutter#126403.
Is this fix for the namespace error pushed to stable? |
@camsim99 can you follow up on this with cherry picks to beta/stable if this change is not in either? |
…6963) Adds `namespace` to module `build.gradle` file templates. Fixes flutter#126403.
I believe this is true and the fix is not part of Flutter 3.10.4. Sorry about the confusion! |
I'm battling with this, I have a Flutter app. The upgrade agent / scripts removed the namespace from the manifest and added it to the app's All of the StackOverflow entries I found so far are garbage, I suspected my case would be quite common. People advise to simply remove the namespace (going against the error message) and similar things. |
In Flutter modules, you need to ensure that |
Closing this issue as this is fixed in |
@camsim99 i was checkout master branch and still got the same error |
Maybe this is off-topic because I landed here mostly as an app developer. I don't have a In my case when the error complains about modules it is about some subset of plugins which lack the namespace. The main issue could be that looking at the error from a mile in Android Studio it is generic and does not tell if it's about the app itself or a plugin, and which plugin exactly. Only when looking at details turns out that it's about some plugins. Community plugins and SDK plugins have now conditional namespace in the App developers might land here. Newer Android studio will advise them of the AGP 8.0+ upgrade. Once they go through with it some lagging plugins which drag their feet could hold their whole project back. This ("outside" lagging plugins) is out of jurisdiction of the SDK and the community plugins repositories, but I just document this here because it could be an issue overall. Just a few examples: |
@MrCsabaToth Thank you for in-depth explanation! You make a great point about developers discovering this issue in ways not directly related to using Flutter in an add-to-app context. If you would be open to it, we would be greatly appreciative for you to answer questions about this with essentially your explanation above if you run into them so that developers can see the solution more clearly. For example: |
This is a fix for the |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Is there an existing issue for this?
Steps to reproduce
Create a new android app and add a new flutter module to it using steps in option 2 : https://docs.flutter.dev/add-to-app/android/project-setup
run 'flutter pub get' in module to build .android folder
sync project in android studio
Expected results
build is successful
Actual results
app fails to build.
Android studio is looking for 'namespace' setting in .android/build.gradle. adding a value manually makes the app build but this is a generated .android folder so any further runs of 'flutter pub get' to update dependencies remove any edits.
Error happens with 3.7.12-stable and 3.10.0-1.5.pre-beta
error output:
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: