Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

missing package attribute in AndroidManifest.xml when create a project with flutter create

Tags:

flutter

I created a flutter project with flutter create chat_app in terminal. But the package attribute in the AndroidManifest.xml is missing. How to fix this?

Thank you in advance.

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <application
        android:label="chat_app"
        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>

I tried flutter create --org com.chat_app chat_app but it didn't work.

like image 821
Jade Avatar asked Oct 18 '25 19:10

Jade


1 Answers

Your AndroidManifest.xml is missing the package attribute, because it was removed from the flutter CLI tool template. It is deprecated. It was removed in this PR.

In the Gradle-based build system, starting with AGP 7.3, don't set the package value in the source manifest file directly. For more information, see Set the application ID.

— https://developer.android.com/guide/topics/manifest/manifest-element#package

Your android/app/build.gradle should have a namespace statement in the android {} with the package instead like so:

// ...

android {
  namespace "com.chat_app"

  // ...
}
like image 57
Albert221 Avatar answered Oct 20 '25 10:10

Albert221



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!