How to change app package name in Flutter without using Android Studio?

Viewed 11327

As you know, app package name (**com.****.******) is very important thing in Flutter app, it is also being used in app's link on Play Store, and some other places.

So, I have a app package name which is automatically created by flutter when creating app via command line: com.example.app

How can I change it properly? There are lots of files and folders named after the app package name, so changing app package name manually without causing error is something I seek.

5 Answers

You need to change it in

  • android/app/build.gradle
  • android/app/src/main/kotlin/com/example/personal_web/MainActivity.kt
  • android/app/src/main/AndroidManifest.xml

There's a useful package for changing it but it works well with android, I didn't try for IOS.

Firstly install the package:

  change_app_package_name: ^1.0.0

Then in terminal in your project paths do these commands:

flutter pub get

Then write the line below and use the unique name you want after com. then press enter:

flutter pub run change_app_package_name:main com.myuniquename.flutter_app

it will update files and delete old package name.

You need to change it in the following files.

  • android/app/build.gradle
  • android/app/src/main/kotlin/com/example/personal_web/MainActivity.kt
  • android/app/src/main/AndroidManifest.xml
  • android/app/src/main/profile/AndroidManifest.xml
  • android/app/src/debug/AndroidManifest.xml

From the documentation:

Your application ID is defined with the applicationId property in your module's build.gradle file [...]

Flutter: Open /android/app/build.gradle, scroll down to applicationId.

The most appropriate command would be flutter create --org com.changehere -a kotlin -i swift yourapp_name

Related