flyingfishcattle
flyingfishcattle

Reputation: 2153

No `<meta-data android:name="flutterEmbedding" android:value="2"/>` in "..\src\main\AndroidManifest.xml"

Trying to run a Flutter application with the flutter run command produces the following error:

No `<meta-data android:name="flutterEmbedding" android:value="2"/>` in   "..\src\main\AndroidManifest.xml"

Here is my AndroidManifest.xml file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.coding.informer.simple_material_app">

    <uses-permission android:name="android.permission.INTERNET"/>

    <application android:name="${applicationName}" android:label="simple_material_app" android:icon="@mipmap/ic_launcher">
        <activity android:name=".MainActivity"
                  android:launchMode="singleTop"
                  android:theme="@android:style/Theme.Black.NoTitleBar"
                  android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
                  android:hardwareAccelerated="true"
                  android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>
</manifest>

I'm aware that the error message offers an obvious solution but I want to post my answer here so that anyone else running into this error can resolve it quickly.

Upvotes: 7

Views: 9537

Answers (3)

Sanjay Bharwani
Sanjay Bharwani

Reputation: 4799

Faced the same problem running a test code as part of udemy course from GitHub repo dicee-flutter

As you can see, my flutter version is 3.16.9

flutter --version
Flutter 3.16.9 • channel stable • https://github.com/flutter/flutter.git

And my dart version is 3.2.6

  dart --version
Dart SDK version: 3.2.6 (stable) (Wed Jan 24 13:41:58 2024 +0000) on "macos_x64"

As the error says you are missing the said meta-data tag in AndroidManifest.xml.

So please add one.

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

Full AndroidManifest.xml to understand the structure.

<application
        android:name="${applicationName}"
        android:label="dicee"
        android:icon="@mipmap/ic_launcher">
        <activity
            android:name=".MainActivity"
            android:launchMode="singleTop"
            android:theme="@style/LaunchTheme"
            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection|fontScale|screenLayout|density"
            android:hardwareAccelerated="true"
            android:windowSoftInputMode="adjustResize">
            
            <meta-data
      android:name="io.flutter.embedding.android.SplashScreenDrawable"
                android:resource="@drawable/launch_background" />
            <!-- Theme to apply as soon as Flutter begins rendering frames -->
            <meta-data
               android:name="io.flutter.embedding.android.NormalTheme"
                android:resource="@style/NormalTheme"
                />
            <meta-data
                android:name="flutterEmbedding"
                android:value="2" />
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>

Upvotes: 0

Hardik Mehta
Hardik Mehta

Reputation: 2415

It will inside application tag. Please see attached :enter image description here

So your manifest fill wiil be look like this :

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.coding.informer.simple_material_app">

    <uses-permission android:name="android.permission.INTERNET"/>
    

    <application android:name="${applicationName}" android:label="simple_material_app" android:icon="@mipmap/ic_launcher">
        <activity android:name=".MainActivity"
                  android:launchMode="singleTop"
                  android:theme="@android:style/Theme.Black.NoTitleBar"
                  android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
                  android:hardwareAccelerated="true"
                  android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>


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

    </application>
</manifest>

Upvotes: 1

flyingfishcattle
flyingfishcattle

Reputation: 2153

The problem was that the AndroidManifest.xml file was lacking a required <meta-data android:name="flutterEmbedding" android:value="2"/> tag. Add it like so:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.coding.informer.simple_material_app">

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

    <application android:name="${applicationName}" android:label="simple_material_app" android:icon="@mipmap/ic_launcher">
        <activity android:name=".MainActivity"
                  android:launchMode="singleTop"
                  android:theme="@android:style/Theme.Black.NoTitleBar"
                  android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale|layoutDirection"
                  android:hardwareAccelerated="true"
                  android:windowSoftInputMode="adjustResize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>
            </intent-filter>
        </activity>
    </application>
</manifest>

Upvotes: 10

Related Questions