我创建了一个新包,但是当我运行 flutter pub
时出现此错误:
This app is using a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to migrate this app to the V2 embedding.
Take a look at the docs for migrating an app: https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects
The plugin `package_info_plus` requires your app to be migrated to the Android embedding v2. Follow the steps on the migration doc above and re-run this command.
但它是一个包,而不是一个应用程序。
我尝试关注https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects但我的 android 文件夹只包含:
// android/local.properties
sdk.dir=/Users/USERNAME/Library/Android/sdk
flutter.sdk=/Users/PATH_TO_FLUTTER/flutter
和
// android/src/main/java/io/flutter/plugins/GeneratedPluginRegistrant.java
package io.flutter.plugins;
import io.flutter.plugin.common.PluginRegistry;
/**
* Generated file. Do not edit.
*/
public final class GeneratedPluginRegistrant {
public static void registerWith(PluginRegistry registry) {
if (alreadyRegisteredWith(registry)) {
return;
}
}
private static boolean alreadyRegisteredWith(PluginRegistry registry) {
final String key = GeneratedPluginRegistrant.class.getCanonicalName();
if (registry.hasPlugin(key)) {
return true;
}
registry.registrarFor(key);
return false;
}
}
如何解决这个问题?
最佳答案
如果您正在使用 Flutter Package(不是插件/应用程序) 您需要做的就是删除特定于平台的文件夹,其中:
android ios linux macos windows
之后运行这两个命令
flutter clean
flutter pub get
问题解决了!!
说明 flutter 包不需要这些文件夹,因为包通常不包含 native 或平台特定的代码。因此,可以安全地删除这些文件夹以避免 Android 嵌入警告。
关于android - Flutter包错误: This app is using a deprecated version of the Android embedding,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76613724/