[英]Your Flutter application is created using an older version of the Android embedding
Recently I opened my old project and there is a warning right now that nothing like this was happening before最近我打开了我的旧项目,现在有一个警告,以前没有发生过这样的事情
Warning looks like警告看起来像
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.
flutter doctor -v summary flutter医生-v总结
[✓] Flutter (Channel stable, 1.22.2, on Mac OS X 10.15.3 19D76, locale en-GB)
• Flutter version 1.22.2 at /Users/pkimac/Development/flutter
• Framework revision 84f3d28555 (6 weeks ago), 2020-10-15 16:26:19 -0700
• Engine revision b8752bbfff
• Dart version 2.10.2
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/pkimac/Library/Android/sdk
• Platform android-30, build-tools 29.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3.1, Build version 11C504
• CocoaPods version 1.10.0.rc.1
[!] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] Connected device (1 available)
• iPhone 11 Pro (mobile) • 7A52F1D0-79F7-471C-AA62-3C106114A1A9 • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)
! Error: Paresh’s iPhone has recently restarted. Xcode will continue when Paresh’s iPhone is unlocked. (code -14)
! Doctor found issues in 1 category.
What does this mean and how can I solve this warning?这是什么意思,我该如何解决这个警告?
This warning occurs if you have created your project before version 1.12如果您在 1.12 版本之前创建了项目,则会出现此警告
In order to better support the execution environments of adding Flutter to an existing project, the old Android platform-side wrappers hosting the Flutter runtime at io.flutter.app.FlutterActivity
and their associated classes are now deprecated. In order to better support the execution environments of adding Flutter to an existing project, the old Android platform-side wrappers hosting the Flutter runtime at
io.flutter.app.FlutterActivity
and their associated classes are now deprecated. New wrappers at io.flutter.embedding.android.FlutterActivity
and associated classes now replace them. io.flutter.embedding.android.FlutterActivity
和相关类的新包装器现在替换它们。
Your existing full-Flutter projects aren't immediately affected and will continue to work as before for the foreseeable future.您现有的完整 Flutter 项目不会立即受到影响,并且在可预见的未来将继续像以前一样工作。
To migrate your project, follow the following steps:要迁移您的项目,请执行以下步骤:
Remove the body of your MainActivity.java
or MainActivity.kt
and change the FlutterActivity
import.删除
MainActivity.java
或MainActivity.kt
的主体并更改FlutterActivity
导入。 The new FlutterActivity
no longer requires manually registering your plugins.新的
FlutterActivity
不再需要手动注册你的插件。 It will now perform the registration automatically when the underlaying FlutterEngine
is created.它现在将在创建底层
FlutterEngine
时自动执行注册。 your file should be like this你的文件应该是这样的
package com.appname.app import io.flutter.embedding.android.FlutterActivity class MainActivity: FlutterActivity() { }
If you had existing custom platform channel handling code in your MainActivity.java
or MainActivity.kt
then move the channel registration part of the code in your onCreate into the configureFlutterEngine override of the FlutterActivity
subclass and use flutterEngine.getDartExecutor().getBinaryMessenger()
as the binary messenger rather than getFlutterView()
.如果您的
MainActivity.java
或MainActivity.kt
中有现有的自定义平台通道处理代码,则将 onCreate 中代码的通道注册部分移动到FlutterActivity
子类的 configureFlutterEngine 覆盖中,并使用flutterEngine.getDartExecutor().getBinaryMessenger()
作为二进制信使而不是getFlutterView()
。
Open android/app/src/main/AndroidManifest.xml.打开 android/app/src/main/AndroidManifest.xml。
Remove the reference to FlutterApplication from the application tag.从应用程序标签中删除对 FlutterApplication 的引用。 and your file should be like this
你的文件应该是这样的
Previous configuration:以前的配置:
<application android:name="io.flutter.app.FlutterApplication" > <!-- code omitted --> </application>
New configuration:新配置:
<application > <!-- code omitted --> </application>
Update splash screen behavior (if splash behavior is desired).更新闪屏行为(如果需要闪屏行为)。
In AndroidManifest.xml
remove all <meta-data>
tags with key android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
. In
AndroidManifest.xml
remove all <meta-data>
tags with key android:name="io.flutter.app.android.SplashScreenUntilFirstFrame"
.
Add a new <meta-data>
tag under <application>
.在
<application>
下添加一个新的<meta-data>
标签。
<meta-data android:name="flutterEmbedding" android:value="2" />
For more info see: https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects#full-flutter-app-migration有关更多信息,请参阅: https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects#full-flutter-app-migration
https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects
Your project is created with older Android version.您的项目是使用较旧的 Android 版本创建的。 If you created your project prior to version 1.12, this may apply to your project.
如果您在 1.12 版之前创建了项目,这可能适用于您的项目。 For now it will not effect your application running but I advice to upgrade it.
目前它不会影响您的应用程序运行,但我建议升级它。 You can follow instructions how to upgrading through link I shared.
您可以按照说明如何通过我共享的链接进行升级。
Flutter 2.2.2
Android Studio - 2020.3.1 Patch 3
Old apps and even creating new Flutter app, would not run and show warning mentioned by OP.旧应用程序甚至创建新的 Flutter 应用程序都不会运行并显示 OP 提到的警告。
I tried migration but that didn't work.我尝试了迁移,但没有奏效。 Finally installed the latest version (2.5.3 ) from https://docs.flutter.dev/get-started/install/windows
终于从https://docs.flutter.dev/get-started/install/windows安装了最新版本(2.5.3)
As advised in above link added below two to path variables (Windows 10)正如上面链接中所建议的那样,在路径变量下面添加了两个(Windows 10)
C:\path-to-flutter-sdk\bin\
C:\path-to-dart-sdk\bin\
After upgrade, Old and new app worked with out any additional modification.升级后,新旧应用程序无需任何额外修改即可工作。
from my Windows 10 device从我的 Windows 10 设备
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.