Change Android PackageName

To change the package name (also known as the applicationId) of a Flutter project for the Android platform, you need to follow these steps:

  1. Update AndroidManifest.xml:

Open the android/app/src/main/AndroidManifest.xml file. Change the package attribute of the element to your new package name (com.yourdomain.yourname in your case).

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.yourdomain.yourname">

To change the App display name below app icon you need to change the field android:label as shown below

    <application
        android:label="YOUR APP NAME"
        
        <activity
            ...
        </activity>
        
    </application>
  1. Update build.gradle:

Open the android/app/build.gradle file. Change the namespace & applicationId to your new package name.

android {
    namespace "com.yourdomain.yourname"
    ...
    defaultConfig {
        ...
        applicationId "com.yourdomain.yourname"
        ...
    }
}
  1. Rename Package Directory:

Rename the existing com/example/test directory to com/yourdomain/yourname in the android/app/src/main/kotlin/ directory.

  1. Change package name in MainActivity.kt:

Change the package name to com.yourdomain.yourname in MainActivity.kt file located in the android/app/src/main/kotlin/com/yourdomain/yourname directory.

package com.yourdomain.yourname

import io.flutter.embedding.android.FlutterActivity

class MainActivity: FlutterActivity() {
}
  1. Run flutter clean and Rebuild:

Run flutter clean in the terminal to clear any previous build artifacts. Rebuild your project by running flutter build.

Last updated