"Build failed due to use of deprecated Android v1 embedding" when building Flutter app

Viewed 55018
to migrate your project. You may also pass the --ignore-deprecation flag to
ignore this check and continue with the deprecated v1 embedding. However,
the v1 Android embedding will be removed in future versions of Flutter.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
The detected reason was:

  C:\Users\ALI HASSAN\OneDrive\Desktop\New folder\arcore_app\example\android\app\src\main\AndroidManifest.xml uses
  `android:name="io.flutter.app.FutterApplication"`
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Build failed due to use of deprecated Android v1 embedding.
6 Answers

You need to change the android\app\src\main\AndroidManifest.xml file.

From :

<application
    android:name="io.flutter.app.FlutterApplication"
    ...

To :

<application
        android:name="${applicationName}"
        ...

add this three lines if doesn't exist :

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

This is used by the Flutter tool to generate GeneratedPluginRegistrant.java.

Change the android AndroidManifest.xml file

<application
    android:name="io.flutter.app.FlutterApplication"
...
 </application>

TO

android:name="${applicationName}"

Also added these two lines

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

You can find the solution by creating a new project with the latest sdk and compare the two project's android\app\src\main\AndroidManifest.xml file.

Depending on what you're doing, you could choose to ignore the error.

I, for example, am following an online class which provides template code for each lesson. However, the template code is out of date and I do not really need to migrate it to proceed.

In Android Studio this can be achieved by adding the --ignore-deprecation flag to the 'Additional run args:' field:

Ignore deprecation

in Main Manifest.xml file ,

set android:exported = "false".

other Solution is ,

in app gradle ,

change Targetsdkversion to 30 and Compilesdkversion to 31

worked for me

Exactly as the error tells you you're using a deprecated embedding version. To upgrade to a newer version please do the following :

  1. Navigate to android/app/src/main/java/[your/package/name]/MainActivity.java open MainActivity.java or MainActivity.kt.

  2. Delete the following dependencies

    import android.os.Bundle;
    import io.flutter.app.FlutterActivity;
    import io.flutter.plugins.GeneratedPluginRegistrant;
    

and replace them with the following line

import io.flutter.embedding.android.FlutterActivity;
  1. Open android/app/src/main/AndroidManifest.xml.

  2. Replace the reference to FlutterApplication in the application tag with ${applicationName} as following

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

5.Remove all tags with key android:name="io.flutter.app.android.SplashScreenUntilFirstFrame". and Add a new tag under application.

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

after that everything should be working fine

Related