Skip to content

Commit 9e0df25

Browse files
authored
Show a warning when a module uses a v1 only plugin (#44499)
1 parent 159a47d commit 9e0df25

File tree

3 files changed

+194
-133
lines changed

3 files changed

+194
-133
lines changed

packages/flutter_tools/lib/src/plugins.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,16 @@ Future<void> _writeAndroidPluginRegistrant(FlutterProject project, List<Plugin>
402402
for (Map<String, dynamic> plugin in androidPlugins) {
403403
if (plugin['supportsEmbeddingV1'] && !plugin['supportsEmbeddingV2']) {
404404
templateContext['needsShim'] = true;
405+
if (project.isModule) {
406+
printStatus(
407+
'The plugin `${plugin['name']}` is built using an older version '
408+
"of the Android plugin API which assumes that it's running in a "
409+
'full-Flutter environment. It may have undefined behaviors when '
410+
'Flutter is integrated into an existing app as a module.\n'
411+
'The plugin can be updated to the v2 Android Plugin APIs by '
412+
'following https://flutter.dev/go/android-plugin-migration.'
413+
);
414+
}
405415
break;
406416
}
407417
}

packages/flutter_tools/lib/src/project.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,11 @@ class AndroidProject {
645645
}
646646

647647
AndroidEmbeddingVersion getEmbeddingVersion() {
648+
if (isModule) {
649+
// A module type's Android project is used in add-to-app scenarios and
650+
// only supports the V2 embedding.
651+
return AndroidEmbeddingVersion.v2;
652+
}
648653
if (appManifestFile == null || !appManifestFile.existsSync()) {
649654
return AndroidEmbeddingVersion.v1;
650655
}

0 commit comments

Comments
 (0)