android - Flutter包错误: This app is using a deprecated version of the Android embedding

标签 android flutter dart embedding flutter-packages

我创建了一个新包,但是当我运行 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/

相关文章:

firebase - Flutter-PlatformException:错误,无效的文档引用。文档引用的段数必须为偶数,但用户的段数为1,则为null

java - pmd:UseConcurrentHashMap 不工作?

Flutter - 调整网络图像大小

android - 在构建Home()时引发了以下NoSuchMethodError:在null上调用了 '>'方法。接收方:null尝试调用:>(1)

ios - 在没有 Xcode 的情况下,在 Flutter 中将 GoogleService-Info.plist 保存在哪里?

dart - 具有水平列表和网格的 Flutter 可滚动主体作为子项

Android - 在 TextView 之间实现拖放

android - 使用 JNI 和 NDK 旋转位图

android - 为什么未检测到网络连接更改?

list - 在 forEach 循环中填充列表之前,我的异步调用正在返回