Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
e1ae4dfc
Unverified
Commit
e1ae4dfc
authored
Aug 20, 2020
by
xster
Committed by
GitHub
Aug 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move v1 embedding migration warning from plugin consumers to all apps (#64181)
parent
a1097d70
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
8 deletions
+57
-8
plugins.dart
packages/flutter_tools/lib/src/plugins.dart
+0
-6
project.dart
packages/flutter_tools/lib/src/project.dart
+17
-0
create_test.dart
...tter_tools/test/commands.shard/permeable/create_test.dart
+25
-0
plugins_test.dart
packages/flutter_tools/test/general.shard/plugins_test.dart
+1
-2
project_test.dart
packages/flutter_tools/test/general.shard/project_test.dart
+14
-0
No files found.
packages/flutter_tools/lib/src/plugins.dart
View file @
e1ae4dfc
...
@@ -661,12 +661,6 @@ Future<void> _writeAndroidPluginRegistrant(FlutterProject project, List<Plugin>
...
@@ -661,12 +661,6 @@ Future<void> _writeAndroidPluginRegistrant(FlutterProject project, List<Plugin>
break
;
break
;
case
AndroidEmbeddingVersion
.
v1
:
case
AndroidEmbeddingVersion
.
v1
:
default
:
default
:
globals
.
printStatus
(
'Your Flutter application is created using an older version of the '
"Android embedding. It's being deprecated in favor of Android embedding "
'v2. Follow the steps on https://flutter.dev/go/android-project-migration '
'to migrate your project.'
);
for
(
final
Map
<
String
,
dynamic
>
plugin
in
androidPlugins
)
{
for
(
final
Map
<
String
,
dynamic
>
plugin
in
androidPlugins
)
{
if
(!(
plugin
[
'supportsEmbeddingV1'
]
as
bool
)
&&
plugin
[
'supportsEmbeddingV2'
]
as
bool
)
{
if
(!(
plugin
[
'supportsEmbeddingV1'
]
as
bool
)
&&
plugin
[
'supportsEmbeddingV2'
]
as
bool
)
{
throwToolExit
(
throwToolExit
(
...
...
packages/flutter_tools/lib/src/project.dart
View file @
e1ae4dfc
...
@@ -756,6 +756,23 @@ class AndroidProject extends FlutterProjectPlatform {
...
@@ -756,6 +756,23 @@ class AndroidProject extends FlutterProjectPlatform {
}
}
Future
<
void
>
ensureReadyForPlatformSpecificTooling
()
async
{
Future
<
void
>
ensureReadyForPlatformSpecificTooling
()
async
{
if
(
getEmbeddingVersion
()
==
AndroidEmbeddingVersion
.
v1
)
{
globals
.
printStatus
(
"""
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Warning
──────────────────────────────────────────────────────────────────────────────
Your Flutter application is created using an older version of the Android
embedding. It's being deprecated in favor of Android embedding v2. Follow the
steps at
https://flutter.dev/go/android-project-migration
to migrate your project.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
"""
);
}
if
(
isModule
&&
_shouldRegenerateFromTemplate
())
{
if
(
isModule
&&
_shouldRegenerateFromTemplate
())
{
await
_regenerateLibrary
();
await
_regenerateLibrary
();
// Add ephemeral host app, if an editable host app does not already exist.
// Add ephemeral host app, if an editable host app does not already exist.
...
...
packages/flutter_tools/test/commands.shard/permeable/create_test.dart
View file @
e1ae4dfc
...
@@ -654,6 +654,31 @@ void main() {
...
@@ -654,6 +654,31 @@ void main() {
expect
(
actualContents
.
contains
(
'useAndroidX'
),
true
);
expect
(
actualContents
.
contains
(
'useAndroidX'
),
true
);
});
});
testUsingContext
(
'creating a new project should create v2 embedding and never show an Android v1 deprecation warning'
,
()
async
{
Cache
.
flutterRoot
=
'../..'
;
when
(
mockFlutterVersion
.
frameworkRevision
).
thenReturn
(
frameworkRevision
);
when
(
mockFlutterVersion
.
channel
).
thenReturn
(
frameworkChannel
);
final
CreateCommand
command
=
CreateCommand
();
final
CommandRunner
<
void
>
runner
=
createTestCommandRunner
(
command
);
await
runner
.
run
(<
String
>[
'create'
,
'--no-pub'
,
'--platforms'
,
'android'
,
projectDir
.
path
]);
final
String
androidManifest
=
await
globals
.
fs
.
file
(
projectDir
.
path
+
'/android/app/src/main/AndroidManifest.xml'
).
readAsString
();
expect
(
androidManifest
.
contains
(
'android:name="flutterEmbedding"'
),
true
);
expect
(
androidManifest
.
contains
(
'android:value="2"'
),
true
);
final
String
mainActivity
=
await
globals
.
fs
.
file
(
projectDir
.
path
+
'/android/app/src/main/kotlin/com/example/flutter_project/MainActivity.kt'
).
readAsString
();
// Import for the new embedding class.
expect
(
mainActivity
.
contains
(
'import io.flutter.embedding.android.FlutterActivity'
),
true
);
expect
(
testLogger
.
statusText
,
isNot
(
contains
(
'https://flutter.dev/go/android-project-migration'
)));
});
testUsingContext
(
'app supports Linux if requested'
,
()
async
{
testUsingContext
(
'app supports Linux if requested'
,
()
async
{
Cache
.
flutterRoot
=
'../..'
;
Cache
.
flutterRoot
=
'../..'
;
when
(
mockFlutterVersion
.
frameworkRevision
).
thenReturn
(
frameworkRevision
);
when
(
mockFlutterVersion
.
frameworkRevision
).
thenReturn
(
frameworkRevision
);
...
...
packages/flutter_tools/test/general.shard/plugins_test.dart
View file @
e1ae4dfc
...
@@ -638,7 +638,7 @@ dependencies:
...
@@ -638,7 +638,7 @@ dependencies:
XcodeProjectInterpreter:
()
=>
xcodeProjectInterpreter
,
XcodeProjectInterpreter:
()
=>
xcodeProjectInterpreter
,
});
});
testUsingContext
(
'old embedding app uses a plugin that supports v1 and v2 embedding works
but shows a deprecation warning
'
,
()
async
{
testUsingContext
(
'old embedding app uses a plugin that supports v1 and v2 embedding works'
,
()
async
{
when
(
flutterProject
.
isModule
).
thenReturn
(
false
);
when
(
flutterProject
.
isModule
).
thenReturn
(
false
);
when
(
androidProject
.
getEmbeddingVersion
()).
thenReturn
(
AndroidEmbeddingVersion
.
v1
);
when
(
androidProject
.
getEmbeddingVersion
()).
thenReturn
(
AndroidEmbeddingVersion
.
v1
);
...
@@ -655,7 +655,6 @@ dependencies:
...
@@ -655,7 +655,6 @@ dependencies:
expect
(
registrant
.
readAsStringSync
(),
contains
(
'class GeneratedPluginRegistrant'
));
expect
(
registrant
.
readAsStringSync
(),
contains
(
'class GeneratedPluginRegistrant'
));
expect
(
registrant
.
readAsStringSync
(),
expect
(
registrant
.
readAsStringSync
(),
contains
(
'UseBothEmbedding.registerWith(registry.registrarFor("plugin4.UseBothEmbedding"));'
));
contains
(
'UseBothEmbedding.registerWith(registry.registrarFor("plugin4.UseBothEmbedding"));'
));
expect
(
testLogger
.
statusText
,
contains
(
'Follow the steps on https://flutter.dev/go/android-project-migration'
));
},
overrides:
<
Type
,
Generator
>{
},
overrides:
<
Type
,
Generator
>{
FileSystem:
()
=>
fs
,
FileSystem:
()
=>
fs
,
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
ProcessManager:
()
=>
FakeProcessManager
.
any
(),
...
...
packages/flutter_tools/test/general.shard/project_test.dart
View file @
e1ae4dfc
...
@@ -148,6 +148,20 @@ void main() {
...
@@ -148,6 +148,20 @@ void main() {
await
project
.
ensureReadyForPlatformSpecificTooling
();
await
project
.
ensureReadyForPlatformSpecificTooling
();
expectExists
(
project
.
android
.
hostAppGradleRoot
.
childFile
(
'local.properties'
));
expectExists
(
project
.
android
.
hostAppGradleRoot
.
childFile
(
'local.properties'
));
});
});
_testInMemory
(
'Android project not on v2 embedding shows a warning'
,
()
async
{
final
FlutterProject
project
=
await
someProject
();
// The default someProject with an empty <manifest> already indicates
// v1 embedding, as opposed to having <meta-data
// android:name="flutterEmbedding" android:value="2" />.
await
project
.
ensureReadyForPlatformSpecificTooling
();
expect
(
testLogger
.
statusText
,
contains
(
'https://flutter.dev/go/android-project-migration'
));
});
_testInMemory
(
'updates local properties for Android'
,
()
async
{
final
FlutterProject
project
=
await
someProject
();
await
project
.
ensureReadyForPlatformSpecificTooling
();
expectExists
(
project
.
android
.
hostAppGradleRoot
.
childFile
(
'local.properties'
));
});
testUsingContext
(
'injects plugins for macOS'
,
()
async
{
testUsingContext
(
'injects plugins for macOS'
,
()
async
{
final
FlutterProject
project
=
await
someProject
();
final
FlutterProject
project
=
await
someProject
();
project
.
macos
.
managedDirectory
.
createSync
(
recursive:
true
);
project
.
macos
.
managedDirectory
.
createSync
(
recursive:
true
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment