Change Android Package Name

The provided documentation outlines the steps to manually change the Android package name for a Flutter application.

Here's a summary of the process:

CHANGE ANDROID PACKAGE NAME MANUALLY

  1. Update build.gradle:

    • Open android/app/build.gradle.
    • Change the applicationId in the defaultConfig block to your new package name.
      defaultConfig {
          applicationId "com.yourcompany.yourapp" // Change this line
          minSdkVersion 21
          targetSdkVersion 33
          versionCode 1
          versionName "1.0.0"
      }
      
  2. Update AndroidManifest.xml:

    • Update the package attribute in the <manifest> tag in the following three files:
      • android/app/src/main/AndroidManifest.xml
      • android/app/src/debug/AndroidManifest.xml
      • android/app/src/profile/AndroidManifest.xml
        <manifest xmlns:android="http://schemas.android.com/apk/res/android"
            package="com.yourcompany.yourapp"> <!-- Change this line -->
        
    • In android/app/src/main/AndroidManifest.xml, ensure 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 (or android/app/src/main/java).
    • Rename the directory structure to reflect your new package name (e.g., if the new package is com.yourcompany.yourapp, the directory structure should be com/yourcompany/yourapp).
    • Open MainActivity.kt (or MainActivity.java).
    • Update the package declaration at the top of the file to your new package name.
      package com.yourcompany.yourapp // Change this line
      
  4. Clean and Rebuild:

    • In your terminal, run flutter clean.
    • Then, run flutter run to rebuild your app with the new package name.

    Flixoo Flixoo