Changing the Android package name is required for Play Store deployment or project cloning. Here’s how to do it safely and cleanly.
Method 1: Using the rename Package #
This is the simplest and fastest way.
🔧 Step-by-Step: #
- Activate the rename tool:
flutter pub global activate rename
- Run the rename command:
flutter pub global run rename --bundleId com.yourcompany.yourapp
This automatically updates:
AndroidManifest.xmlbuild.gradle- Kotlin/Java package paths
MainActivity.kt
Tool GitHub Page: https://pub.dev/packages/rename
Method 2: Manual Way #
Recommended when you want full control or can’t use third-party tools.
Change directory structure #
If your current path is:
android/app/src/main/kotlin/com/example/yourapp
and your new package is:
com.yourcompany.appname
Then change folder names accordingly:
android/app/src/main/kotlin/com/yourcompany/appname
Update the package name in these files: #
android/app/src/main/AndroidManifest.xml
<manifest package="com.yourcompany.appname">
android/app/build.gradle
defaultConfig {
applicationId "com.yourcompany.appname"
}
android/app/src/main/kotlin/.../MainActivity.kt
Change the package line at the top:
package com.yourcompany.appname
Clean and rebuild: #
flutter clean
flutter pub get
flutter run
📝 Notes: #
- Ensure your keystore and signing configs match the new package if you’re publishing.
- Double-check any deep links, Firebase setups, or other integrations that rely on the old package name.