I used react-native init MyApp
to initialise a new React Native app.
This created among others an Android project with the package com.myapp
.
After running this:
react-native-rename "MyApp" -b com.mycompany.myapp
Make sure to also goto Build.gradle
under android/app/...
and rename the application Id as shown below:
defaultConfig {
applicationId:com.appname.xxx
........
}
Follow the simple steps to rename your app name
and Package name
in case you have not made any custom changes in android folder(ie. scenario where u just initialized the project)
name
in the package.json
file as you need and save it.react-native upgrade
Note:As ivoteje50 mentioned in comment,Don't remove the android folder if you have already followed the official instructions to generate a keystore, since it will remove the keystore and you cannot sign a new app again.
In VS Code, press Ctrl + Shift + F
and enter your old package name in 'Find' and enter your new package in 'Replace'. Then press 'Replace all occurrences'.
Definitely not the pragmatic way. But, it's done the trick for me.
Goto Android studio
Right click your package (most probably com)-> Refractor -> Rename -> Enter new package name in the dialog -> Do Refractor
It will rename your package name everywhere.
I've used the react-native-rename package.
In terminal run the command to install:
npm install react-native-rename -g
In the root of your React Native project, run the following command:
react-native-rename "NewNameOfApp" -b com.companyname.newnameofapp
very simple way :
cd /your/project/dir
run this command :
grep -rl "com.your.app" . | xargs sed -i 's/com.your.app/com.yournew.newapp/g'
rename your folder
android/app/src/main/java/com/your/app
change to
android/app/src/main/java/com/yournew/newapp