You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#10288 added a formal way to allow plugins to indicate which platforms they support, but any plugin that doesn't support Android (as in, has no android/ folder) will cause Gradle failures. It looks from initial investigation like this is because flutter.gradle uses .flutter-plugins, which isn't platform-specific and thus isn't subject to platform filtering.
Presumably we should move away from having a single .flutter-plugins at all, and migrate all current clients to new platform-specific versions.
Currently the only way to make, say, a desktop-specific plugin that doesn't break Android is with a dummy directory.
This makes sense. @amirh's proposal: "Distributed Platform Ownership for Flutter Plugins" touches on this--we could start by listing the platforms in the plugin's pubspec file. I saw you made some comments in the doc, is there general agreement around that (pubspec schema at least)?
we could start by listing the platforms in the plugin's pubspec file
#38632 already added support for that. This bug is specifically about making the right thing happen when you don't list Android there, which currently isn't the case.
We might still need .flutter-plugins though, but maybe we can split it by platform? Ootherwise, we need to pass the plugin list to Gradle as an argument, but that breaks add to app scenarios where the host app is built from Android Studio instead of the Flutter tool.
So I guess the plan is to split .flutter-plugins into multiple .flutter-plugins-<platform> files. It sounds like we will need to implement auto-migration for for the gradle/xcode stuff (e.g the tool will update existing settings.gradle to refer to .flutter-plugins-android).
We don't necessary have to migrate; we could keep making .flutter-plugins for all existing projects, and tell people who want to start using plugins that don't support all of their project's platforms to manually delete the appropriate files (e.g., Podspec) and rebuild so it would generate a new version.
I think there are a few independent pieces of work here.
One would be for all of the tooling to gracefully handle a missing plugin implementation. This would at least unblock work in the short-term even it isn't the final strategy.
Separately, rather than create N .flutter-plugins-platform files I think we should update the tooling to look in the platform projects' ephemeral/output directory and then fall back to the project root. We can output platform specific .flutter-plugins in these directories without breaking any current workflows.
Once that is done, we can evaluate the cost of removing the project root plugins
One would be for all of the tooling to gracefully handle a missing plugin implementation. This would at least unblock work in the short-term even it isn't the final strategy.
@jonahwilliams can you sketch how you envision that? (to make sure we're all on the same page)
In the android case, it would mean updating flutter.gradle to check for the correct files before creating a plugin task here:
This also requires changes to android/settings.gradle since the plugins are still included as subprojects in app projects.
Separately, rather than create N .flutter-plugins-platform files I think we should update the tooling to look in the platform projects' ephemeral/output directory and then fall back to the project root.
@jonahwilliams This sounds good too. Do you plan to change flutter create so that it takes the list of target platforms as an argument?
I prototyped excluding plugins without an android/build.gradle file from the list of plugins we're building in amirh@bdcf4c5. It seem to work, though I know very little about Gradle so am likely missing something. @blasten what should I expect to break if I didn't change anything in android/settings.gradle?
Also - do we have a reasonable harness to test such a thing?
Echoing my comment from the iOS bug: what's the advantage of doing this?
I see this as a general tool hardening, we shouldn't crash if files/folders are missing in easily anticipated ways. The fact that it unblocks some work temporarily is just a side effect.
Echoing my comment from the iOS bug: what's the advantage of doing this? This is the same file we'd need to change to point it to a different, Android-specific .flutter-plugins file, so this is doing more throw-away work with no benefit that I can see. Generating these platform-specific files in Dart should be trivial given that we already have all the code for filtering plugins by platform, including handling of fallbacks depending on whether or not plugins are using the new or old schema. And if we do that once, we can do iOS and Android the way we want to support long term right now, without an intermediate step.
I'm not sure how simple and/or reliable can the auto migration of existing apps' settings.gradle be (which currently points to `.flutter-plugins), without that migration we need something like the current patch.
Oh, I missed that this is a file that's part of Flutter itself, not the project. I was assuming it would be similar to iOS, where the file is generated into the project and then left there, requiring some kind of update (migrated or manual). If we can retroactively fix all existing projects to handle this gracefully I definitely understand why it's worth doing.
I started playing around with generating platform-specific plugin files; WIP here. It's totally untested (even manually), and we'd need to figure out if those are the right file locations on mobile, but I think that's basically the right structure.
Then we can incrementally work on removing all internal use of .flutter-plugins, except for continuing to write it for existing projects until/unless we migrate them.
I'm not sure when I'll have time to continue with that so if someone wants to take that and turn it into a real PR please feel free.
@jmagman That's an obsolete PR for now. The JSON logic has already landed. The migration part will be discussed here , which might depend on the decisions taken in this proposal
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 flutter doctor -v and a minimal reproduction of the issue.
Activity
blasten commentedon Sep 4, 2019
This makes sense. @amirh's proposal: "Distributed Platform Ownership for Flutter Plugins" touches on this--we could start by listing the platforms in the plugin's pubspec file. I saw you made some comments in the doc, is there general agreement around that (pubspec schema at least)?
stuartmorgan-g commentedon Sep 4, 2019
#38632 already added support for that. This bug is specifically about making the right thing happen when you don't list Android there, which currently isn't the case.
blasten commentedon Sep 4, 2019
oh excellent. I wasn't aware of that.
We might still need
.flutter-pluginsthough, but maybe we can split it by platform? Ootherwise, we need to pass the plugin list to Gradle as an argument, but that breaks add to app scenarios where the host app is built from Android Studio instead of the Flutter tool.stuartmorgan-g commentedon Sep 4, 2019
That's what I meant by "new platform-specific versions". (iOS and macOS would also benefit from having such files.)
amirh commentedon Sep 16, 2019
So I guess the plan is to split
.flutter-pluginsinto multiple.flutter-plugins-<platform>files. It sounds like we will need to implement auto-migration for for the gradle/xcode stuff (e.g the tool will update existing settings.gradle to refer to.flutter-plugins-android).Any thoughts? better options?
@blasten @stuartmorgan @jonahwilliams
blasten commentedon Sep 16, 2019
sgtm. One more reason for #40460
stuartmorgan-g commentedon Sep 16, 2019
We don't necessary have to migrate; we could keep making
.flutter-pluginsfor all existing projects, and tell people who want to start using plugins that don't support all of their project's platforms to manually delete the appropriate files (e.g., Podspec) and rebuild so it would generate a new version.Not ideal, but possible.
jonahwilliams commentedon Sep 16, 2019
I think there are a few independent pieces of work here.
One would be for all of the tooling to gracefully handle a missing plugin implementation. This would at least unblock work in the short-term even it isn't the final strategy.
Separately, rather than create N
.flutter-plugins-platformfiles I think we should update the tooling to look in the platform projects' ephemeral/output directory and then fall back to the project root. We can output platform specific .flutter-plugins in these directories without breaking any current workflows.Once that is done, we can evaluate the cost of removing the project root plugins
amirh commentedon Sep 16, 2019
@jonahwilliams can you sketch how you envision that? (to make sure we're all on the same page)
jonahwilliams commentedon Sep 16, 2019
In the android case, it would mean updating
flutter.gradleto check for the correct files before creating a plugin task here:https://github.com/flutter/flutter/blob/master/packages/flutter_tools/gradle/flutter.gradle#L250
Maybe it should print an error or warning, but definitely not crash.
blasten commentedon Sep 16, 2019
This also requires changes to
android/settings.gradlesince the plugins are still included as subprojects in app projects.@jonahwilliams This sounds good too. Do you plan to change
flutter createso that it takes the list of target platforms as an argument?jonahwilliams commentedon Sep 16, 2019
.flutter-plugins is not a part of flutter create.
Ahh yes, that's unfortunate. I would suggest @stuartmorgan's plan then
amirh commentedon Sep 16, 2019
I prototyped excluding plugins without an
android/build.gradlefile from the list of plugins we're building in amirh@bdcf4c5. It seem to work, though I know very little about Gradle so am likely missing something. @blasten what should I expect to break if I didn't change anything inandroid/settings.gradle?Also - do we have a reasonable harness to test such a thing?
4 remaining items
jonahwilliams commentedon Sep 17, 2019
I see this as a general tool hardening, we shouldn't crash if files/folders are missing in easily anticipated ways. The fact that it unblocks some work temporarily is just a side effect.
jonahwilliams commentedon Sep 17, 2019
I agree, it's not much more difficult- we should do that also.
amirh commentedon Sep 17, 2019
I'm not sure how simple and/or reliable can the auto migration of existing apps'
settings.gradlebe (which currently points to `.flutter-plugins), without that migration we need something like the current patch.stuartmorgan-g commentedon Sep 17, 2019
Oh, I missed that this is a file that's part of Flutter itself, not the project. I was assuming it would be similar to iOS, where the file is generated into the project and then left there, requiring some kind of update (migrated or manual). If we can retroactively fix all existing projects to handle this gracefully I definitely understand why it's worth doing.
stuartmorgan-g commentedon Sep 17, 2019
I started playing around with generating platform-specific plugin files; WIP here. It's totally untested (even manually), and we'd need to figure out if those are the right file locations on mobile, but I think that's basically the right structure.
Then we can incrementally work on removing all internal use of
.flutter-plugins, except for continuing to write it for existing projects until/unless we migrate them.I'm not sure when I'll have time to continue with that so if someone wants to take that and turn it into a real PR please feel free.
jmagman commentedon Jan 18, 2020
@franciscojma86 Will this also be fixed by #47258?
franciscojma86 commentedon Jan 21, 2020
@jmagman That's an obsolete PR for now. The JSON logic has already landed. The migration part will be discussed here , which might depend on the decisions taken in this proposal
jmagman commentedon Jan 21, 2020
@franciscojma86 Can this issue be closed? Or is there more work to track here?
franciscojma86 commentedon Jan 21, 2020
We still need no-op implementations for plugins, so we can't close this yet. We will close after we migrate the templates.
blasten commentedon Apr 9, 2020
This issue was fixed by #47015. Plugins that don't have an
android/build.gradlearen't used when building for Android.ditman commentedon Apr 10, 2020
This is great! Does this mean we can remove the noop
androiddirectories from plugin packages?blasten commentedon Apr 10, 2020
Yep! However, I'd wait until the next stable release is rolled out. #46304 is tracking that
lock commentedon Apr 25, 2020
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
flutter doctor -vand a minimal reproduction of the issue.