Changing package name of reactnative project

reactlogo2
reactlogo2

Many of the developers create there reactnative projects using react-native init command.If you open the project and see the package name in the manifest and other files you might observe that the package name is com.projectname rather than com.company.projectname in default android applications.

This might work in initial development stages but eventually you will need to change the project name to upload build to playstore using desired package name.For this very reason the change can be done in following steps:

1)First right-click on gear icon and uncheck the compact empty middle packages option.

reactnativepackage
reactnativepackage

Then right-click on com->projectname folder and open file location by clicking on show in files.

Next create a new folder of company name in com folder and move project folder into the company folder.

Now you can use ctrl+shift+f to search for all occurrences of com.projectname and replace them with com.company.projectname.

Alternatively here are the files in which you need to make changes:

MainActivity.java(first line)

MainApplication.java(first line)

build.gradle(Module:app)

AndroidManifest.xml

Next run rebuild and clean project from build menu and sync the project once to resolve any issues.

Once you are done with this process you can easily refactor the package name for renaming purposes in the future just like normal android application.

That’s it for today’s tutorial.Feel free to post any issues in comments or if you know about a better way.

Share post-
About Saurabh Mhatre 70 Articles
Currently working in web and hybrid application development