Flutter包错误:此应用程序正在使用Android嵌入的已弃用版本。

huangapple go评论80阅读模式
英文:

Flutter package error: This app is using a deprecated version of the Android embedding

问题

我创建了一个新的包,但当我运行 flutter pub get 时出现以下错误:

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;
  }
}

我该如何解决这个问题?

英文:

I've created a new package but when I run flutter pub get this error:

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.

But it's a package and not an app.

I tried following https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects but my android folder only contains:

// android/local.properties

sdk.dir=/Users/USERNAME/Library/Android/sdk
flutter.sdk=/Users/PATH_TO_FLUTTER/flutter

and

// 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;
  }
}

How do I resolve this?

答案1

得分: 3

如果您正在使用Flutter Package(而不是插件/应用程序),您只需要删除以下特定于平台的文件夹:

android ios linux macos windows

之后运行以下两个命令:

flutter clean
flutter pub get

问题解决了!!

解释
这些文件夹对于Flutter包通常不需要,因为包通常不包含本地或特定于平台的代码。因此,可以安全地删除这些文件夹以避免Android嵌入警告。

英文:

if you are working on Flutter Package (not plugin/ app)
All you need to do is delete the platform specific folders which are:

> android ios linux macos windows

after that run these two commands

flutter clean
flutter pub get

Problem Solved!!

explanation
These folders are not required by the flutter packages as packages don't usually include native or platform specific code. So it is safe to remove these folders to avoide the Android Embedding warnings.

huangapple
  • 本文由 发表于 2023年7月4日 22:38:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/76613724.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定