简体   繁体   English

您的 Flutter 应用程序是使用旧版本的 Android 嵌入创建的

[英]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:要迁移您的项目,请执行以下步骤:

  1. Remove the body of your MainActivity.java or MainActivity.kt and change the FlutterActivity import.删除MainActivity.javaMainActivity.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.javaMainActivity.kt中有现有的自定义平台通道处理代码,则将 onCreate 中代码的通道注册部分移动到FlutterActivity子类的 configureFlutterEngine 覆盖中,并使用flutterEngine.getDartExecutor().getBinaryMessenger()作为二进制信使而不是getFlutterView()

  2. Open android/app/src/main/AndroidManifest.xml.打开 android/app/src/main/AndroidManifest.xml。

  3. 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>
  4. 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" .

  5. 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.

相关问题 android应用程序重置为旧版本 - android application resetting to older version 通过Eclipse在旧版本上安装Android应用 - Android application installation on an older version via eclipse Android 应用程序安装警告(为旧版本构建) - Android application install warning (built for older version) 此应用使用的是已弃用的 Android 嵌入版本 - This app is using a deprecated version of the Android embedding 使用旧版本然后Android 4.3检测信标 - Detect beacon using older version then Android 4.3 插件 `kommunicate_flutter` 使用了 Android 嵌入的弃用版本 - The plugin `kommunicate_flutter` uses a deprecated version of the Android embedding 升级到 Flutter 3.3.2 后。 由于“open_file”插件使用已弃用的 Android 嵌入版本,因此无法构建应用程序 - After upgrading to Flutter 3.3.2. can not buld app due to 'open_file' plugin using a deprecated version of the Android embedding 旧版Android上的TaskStackBuilder - TaskStackBuilder on older version Android 针对较旧的Android版本进行开发 - Developing for older Android version Android Studio使用较旧和较新Android版本的API - Android Studio using API from older and newer Android version
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM