Home > Software design >  Flutter build failed due to use of deprecated Android v1 embedding
Flutter build failed due to use of deprecated Android v1 embedding

Time:03-16

Hi guys i have an error in the flutter project that I cloned from GitHub. I tried this method but it didn't work

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

To :

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

can anyone help?

error:

enter image description here

AndroidManifest.xml:

enter image description here

CodePudding user response:

Add the following code in android manifest after activity

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

enter image description here

In project build.gradle add the following code in buildscript

ext.kotlin_version = '1.6.10'

enter image description here

And change gradle version in gradle-wrapper.properties

enter image description here

My manifest file

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.stackoverflowexample">
   <application
        android:label="stackoverflowexample"
        android:name="${applicationName}"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:exported="true"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            <!-- Specifies an Android theme to apply to this Activity as soon as
                 the Android process has started. This theme is visible to the user
                 while the Flutter UI initializes. After that, this theme continues
                 to determine the Window background behind the Flutter UI. -->
            <meta-data
              android:name="io.flutter.embedding.android.NormalTheme"
              android:resource="@style/NormalTheme"
              />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
        <!-- Don't delete the meta-data below.
             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
        <meta-data
            android:name="flutterEmbedding"
            android:value="2" />
    </application>
</manifest>

CodePudding user response:

Add below lines in AndroidManifest.xml file

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

For more details : https://docs.flutter.dev/release/breaking-changes/android-v1-embedding-create-deprecation

CodePudding user response:

It may sound like a fake solution, but indeed, the easiest way to resolve this is:

  1. Delete the android folder.
  2. Run flutter create .

The command will recreate the android folder with the already migrated code. Also, the command will create folders for the other stable platforms (e.g. web, windows), so you could ignore those and just delete them or trigger the flutter create command by defining android - flutter create --platforms=android ..

  • Related