“..\src\main\AndroidManifest.xml”中没有 `<meta-data android:name="flutterEmbedding" android:value="2"/>`

fly*_*tle 7 debugging android android-manifest flutter

尝试使用该flutter run命令运行 Flutter 应用程序会产生以下错误:

No `<meta-data android:name="flutterEmbedding" android:value="2"/>` in   "..\src\main\AndroidManifest.xml"
Run Code Online (Sandbox Code Playgroud)

这是我的AndroidManifest.xml文件:

<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>
Run Code Online (Sandbox Code Playgroud)

我知道错误消息提供了一个明显的解决方案,但我想在这里发布我的答案,以便其他遇到此错误的人可以快速解决它。

fly*_*tle 9

问题是该AndroidManifest.xml文件缺少所需的<meta-data android:name="flutterEmbedding" android:value="2"/>标签。像这样添加:

<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>
Run Code Online (Sandbox Code Playgroud)