AHMED Gamal
AHMED Gamal

Reputation: 73

Flutter build failed due to use of deprecated Android v1 embedding

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

error:

enter image description here

AndroidManifest.xml:

enter image description here

Upvotes: 6

Views: 20167

Answers (5)

Ahmed
Ahmed

Reputation: 21

in AndroidManifest.xml inside <application ... just replace android to: android:name="${applicationName}"

Upvotes: 0

Roslan Amir
Roslan Amir

Reputation: 1336

The best solution I found when I got this problem with my older Flutter projects is to start fresh.

  1. Rename the old project folder.
  2. Create a new Flutter project using the latest Android Studio or command line.
  3. Copy/paste the old code from your backup folder.
  4. Be careful not to replace any of the control files: pubspec.yaml, Android folder, iOS folder, Gradle, etc.
  5. You will find the problem solved.

Upvotes: 3

mkobuolys
mkobuolys

Reputation: 5333

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 platform - flutter create --platforms=android ..

Upvotes: 9

Yashraj
Yashraj

Reputation: 999

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

Upvotes: 2

MORE AKASH
MORE AKASH

Reputation: 333

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>

Upvotes: 2

Related Questions