Your Flutter application is created using an older version of the Android embedding

Your Flutter application is created using an older version of the Android embedding

❗️ What is actually happening?

Recently I downloaded some flutter project from github.

When I ran it, I got an error like below.

image.png

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.


🛠 Issue Solved

This warning occurs if you have created your project before version 1.12.

This is an error that occurs when the classes use in associated with io.flutter.android.FlutterActivity because io.flutter.android.FlutterActivity is now deprecated.

a. change the FlutterActivity import in your MainActivity.java or MainActivity.kt

package com.appname.app

import io.flutter.android.FlutterActivity

class MainActivity: FlutterActivity() {

}

to

package com.appname.app

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {

}

b. replace the reference to FlutterApplication from the application tag in your android/app/src/main/AndroidManifest.xml

<application
   android:name="io.flutter.app.FlutterApplication">
   <!-- code omitted -->
</application>

to

<application
  android:name="${applicationName}">
  <!-- code omitted -->
</application>

c. Add a new <meta-data> tag under <application>

<meta-data
  android:name="flutterEmbedding"
  android:value="2" />



blogcoffee-2 (2).png