How to Change Package Name in Flutter

In android, every app has a unique id. The unique id is very important for identifying the particular app. The id looks like a java package name. You can use your domain name as a package dame. Because the domain name is unique.

Changing the package name in flutter is very easy. Follow the simple steps,

Step 1: Changing Package name in AndroidManifest.xml file (main)

First, go to the android>app> src>main > AndroidManifest.xml file.

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="<strong>com.example.name</strong>">
Code language: HTML, XML (xml)

Find the package name in the first line, then change the package name as per your need.

Step 2: Changing Package name in AndroidManifest.xml file (debug)

Then, go to the android>app> src>debug> AndroidManifest.xml file.

Find the package name and change it.

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="<strong>com.example.name</strong>">
Code language: HTML, XML (xml)

Step 3: Changing Package name in AndroidManifest.xml file (profile)

Then, go to the android>app> src>debug> AndroidManifest.xml file.

Find the package name and change it.

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="<strong>com.example.name</strong>">
Code language: HTML, XML (xml)

Step 4: Changing Package name in build.gradle (App level)

Then, go to the android>app> build.gradle file and change the package name.

defaultConfig { applicationId "<strong>com.example.name</strong>" minSdkVersion 16 targetSdkVersion 30 versionCode flutterVersionCode.toInteger() versionName flutterVersionName }
Code language: HTML, XML (xml)

Step 5: Change the package name in MainActivity.kt

Then, go to the android> app> src> main> kotlin> MainActivity.kt and change the package name.

package <strong>com.example.name</strong> import io.flutter.embedding.android.FlutterActivity class MainActivity: FlutterActivity() { }
Code language: HTML, XML (xml)

Step 6: Changing directory name

Then change the directory name from android\app\src\main\kotlin\com\example\name to android\app\src\main\kotlin\your\package\name .

This is the complete process of changing the package name in the entire flutter app. To avoid renaming use flutter create --org com.yourdomain appname command.

Also Read,