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
Flutter 3.7.12 with native plugin fails with AGP version 8.0+ #125181
Comments
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
In the error there is a clear mention that now you need to add More info in the official docs: |
Version 3.7.12 working perfectly for me. AGP version 7.4.2 and Gradle 8.0 Put your namespace on android/app/build.gradle file android tag |
Thanks for the report! I also can see this issue when adding For anyone facing this issue, please try it to see if it works. |
You don't have dependencies which use native code |
Hi, this namespace need to be added on all build.gradle of the plugins |
juliansteenbakker/mobile_scanner#602 mobile scanner will soon be updated |
I tested one of our plugins with the
My testing was incorrect, see my comments below. It's true for 4.2, but not 4.1. On the Flutter side, we'll need to:
Optional changes:
|
Changed the title since the issue is more closely related to AGP than it is to gradle. |
Adjusting title; the breaking change is in AGP 8.0 |
- Smallest change required to support host apps using agp 8.0 (#125657) Original issue #125181 Cherry pick issue #125688 *If you had to change anything in the [flutter/tests] repo, include a link to the migration guide as per the [breaking change policy].* ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] All existing and new tests are passing.
- Update Gradle/AGP version and add namespace plus dependencies. #125181
Final State:
Closing issue. |
Adds the `namespace` property necessary for AGP 8 compatibility to the plugin templates, with the conditional logic to ensure that it doesn't break AGP <4.2, so that new plugins will be maximally compatible. Part of flutter#125181
Adds the `namespace` property necessary for AGP 8 compatibility to the plugin templates, with the conditional logic to ensure that it doesn't break AGP <4.2, so that new plugins will be maximally compatible. Part of #125181
You can also add this under the subprojects {
//other config
afterEvaluate {
// check if `android` block is available and namespace isn't set
if(it.hasProperty('android') && it.android.namespace == null){
def manifest = new XmlSlurper().parse(file(it.android.sourceSets.main.manifest.srcFile))
def packageName = manifest.@package.text()
print("Setting ${packageName} as android namespace")
android.namespace= packageName
}
}
}
There is also the possibility of running into kotlin jvm compatibility issues for same plugins which are yet to be migrated. Setting For my case affected packages(package_info_plus inclusive like in your case) are working fine. You might want keep track of these packages so when they are fully migrated you can undo these changes. |
It's simple, you don't even need to edit flutter android plugin (android native code)
This will make sure all the sub projects have android namespace, if not it will read it from AndroidManifest.xml, and also set the compileSdkVersion to 33 (you need to change it manually to the latest in the future) and also target java version 17 |
Adds the `namespace` property necessary for AGP 8 compatibility to the plugin templates, with the conditional logic to ensure that it doesn't break AGP <4.2, so that new plugins will be maximally compatible. Part of flutter#125181
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
flutter pub add device_info_plus
(or any other package that has a native component likemobile_scanner
)Expected results
Gradle sync success
Actual results
Gradle sync failure:
Code sample
Code sample
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: