Merge Flutter assets in add to app#41333
Conversation
1f69605 to
c7ed63e
Compare
c7ed63e to
d2b68a6
Compare
| Task cleanPackageAssets = project.tasks.findByPath(":flutter:cleanPackage${variant.name.capitalize()}Assets") | ||
| // In add to app scenarios, :flutter is a subproject of another Android app. | ||
| // We know that :flutter is used as a subproject when these tasks exist. | ||
| boolean isUsedAsSubproject = packageAssets && cleanPackageAssets |
There was a problem hiding this comment.
Are there likely to be false positives or negatives from this? I'm not familiar with either of these, not sure how reliable this is.
There was a problem hiding this comment.
I don't think so since the :flutter project doesn't exist unless the app is using add 2 app and include_flutter.groovy.
I have also added an assert in line 654 to exit early if there isn't a root project named :app.
| // Flutter module included as a subproject in add to app. | ||
| Project appProject = project.rootProject.findProject(':app') | ||
| assert appProject != null | ||
| appProject.afterEvaluate { |
There was a problem hiding this comment.
I know enough to know that afterEvaluate is generally not recommended in Gradle scripts because it works outside of Gradle's normal execution flow, but I don't know enough about what to recommend here instead. :| If this is the only thing that works I think it makes sense to use it, but if there's another option I would prefer that instead.
There was a problem hiding this comment.
yeah. It needs to wait until the Android plugin loads. Otherwise appProject.android is undefined
Looking through the docs, it seems like afterEvaluate is the only way to perform additional configuration after all the definitions in a build script have been applied. I'm not sure if there's a better way other not adding the implicit dependency on AGP.
|
Related Issues #42214.The main android application in the project may not be called maybe it's fixed like this |
|
I encountered this issue as well, it somehow forces me to rename my existing native app module (eg. named as Flutter Doctor View Log
|
|
This is still a problem in May. I am required to rename my app module to "app" instead of it's usual name. |
Description
PR #36805 broke add to app:
flutter_assetsins't in the APK if themergeAssetstasks runs beforeprocessManifest. This is the case if the host app uses the https://fabric.io Gradle plugin.PR #38542 tried to fix this issue, but it didn't add a minimal reproduction / test.
Related Issues
Fixes #38286
Tests
Integration test.
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?