Changing flutter project package name is not easy for those who are new to android development. Recently, I bought an app from Codecanyon, and tried to change the package name for hours, and finally rename it with the help of Bracket’s Find and Replace in Files option. :p After digging the stackoverflow for some time I found this easy way to change flutter package name. It worked like a charm.

Change Flutter app package name with single command.

Requirement

For running this command, you need to add one dependency to your pubspec.yaml file, located at the root of the project.

dev_dependencies: 
change_app_package_name: ^0.1.2

Update Dependency

After adding the dependency, open your terminal and run the following command to update the dependency.

flutter pub get

How to Use?

Now move to your flutter project folder from the terminal and run the below command to change package name.

flutter pub run change_app_package_name:main com.newpackage.name

Replace com.newpackage.name with a package name that you want to add.

What it does?

  • Update AndroidManifest.xml files for release, debug & profile
  • Update build.gradle file
  • Update MainActivity file. Both java & kotlin supported.
  • Move MainActivity file to new package directory structure
  • Delete old package name directory structure

Common Errors

If you run the command without adding and updating the dependency you might end up with the error below.

Could not find package "change_app_package_name". Did you forget to add a dependency?
pub finished with exit code 65
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like