How to Change the Package Name of your Flutter app

Skyblazar LLC
1 min readJun 14, 2019

--

There are 6 main steps to take to successfully change the package name for your flutter app.

Modify the applicationId in your build.gradle file

These steps must be followed meticulously to prevent any potential crash.

1. Modify the package name in your MainActivity.java file

Modify package com.example.app; to reflect your new package name:

<project-name>/android/app/src/main/java/com/example/apppackage com.example.app;import android.os.Bundle;
import io.flutter.app.FlutterActivity;
import io.flutter.plugins.GeneratedPluginRegistrant;

2. Modify the directory containing your MainActivity.java file

Modify the directory structure from:

<project-name>/android/app/src/main/java/com/example/app

to:

<project-name>/android/app/src/main/java/your/package/name

3. Modify the package name in your main AndroidManifest.xml file

Replace "com.example.app" with your new package name:

<project-name>/android/app/src/main<manifest xmlns:android=”http://schemas.android.com/apk/res/android" package=”com.example.app”>

4. Modify the package name in your debug AndroidManifest.xml file

Do the same here:

<project-name>/android/app/src/debug<manifest xmlns:android=”http://schemas.android.com/apk/res/android" package=”com.example.app”>

5. Modify the package name in your profile AndroidManifest.xml file

And here:

<project-name>/android/app/src/profile<manifest xmlns:android=”http://schemas.android.com/apk/res/android" package=”com.example.app”>

6. Modify the applicationId in your build.gradle file

Modify the applicationId to reflect your new package name:

<project-name>/android/app/src/profiledefaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.app"
minSdkVersion 18
targetSdkVersion 28
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}

Lastly, run flutter clean and you’re set.

--

--