Change Android Package Name Manually¶
Changing the Android package name manually is a more involved process, but it gives you full control. Here are the steps to do it:
1. Update build.gradle
¶
- Open
android/app/build.gradle
. -
In the
defaultConfig
block, change theapplicationId
to your new package name.
2. Update AndroidManifest.xml
¶
You need to update the package name in three AndroidManifest.xml
files:
android/app/src/main/AndroidManifest.xml
android/app/src/debug/AndroidManifest.xml
android/app/src/profile/AndroidManifest.xml
In each of these files, update the package
attribute in the <manifest>
tag to your new package name.
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.yourcompany.yourapp">
Also, in android/app/src/main/AndroidManifest.xml
, make sure that the android:name
attribute in the <activity>
tag is correct. It should be ".MainActivity"
.
3. Update MainActivity.kt
(or MainActivity.java
)¶
- Navigate to
android/app/src/main/kotlin
(orandroid/app/src/main/java
). - The directory structure should reflect your new package name. For example, if your new package name is
com.yourcompany.yourapp
, the directory structure should becom/yourcompany/yourapp
. - Rename the directories to match your new package name.
- Open
MainActivity.kt
(orMainActivity.java
). -
Update the
package
declaration at the top of the file to your new package name.
4. Clean and Rebuild¶
- In your terminal, run
flutter clean
. - Then, run
flutter run
to rebuild your app with the new package name.
(Please note that the file paths and package names in your project may be slightly different. The images below show an example of what to look for.)