Search code examples
androidflutterdartembeddingflutter-packages

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


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?


Solution

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