Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the package name in a react-native app

I've created an app in react-native. I need the package name to be: com.org.appname

React-native does not allow you to specify this as the package name in the init, or to change it after init.

react-native init --package="com.org.appname" 

does not work

Changing the package name as described in Change package name for Android in React Native also doesn't work and results in the following error on react-native run-android

Failed to finalize session : INSTALL_FAILED_VERSION_DOWNGRADE

like image 522
Dylan Spencer James Avatar asked Apr 08 '17 11:04

Dylan Spencer James


1 Answers

in iOS project you just need to change BundleID with Xcode.

In Android project you need to change package name in 4 files:

android/app/src/main/java/com/reactNativeSampleApp/MainActivity.java
android/app/src/main/java/com/reactNativeSampleApp/MainApplication.java
android/app/src/main/AndroidManifest.xml
android/app/build.gradle

good practice is also to modify BUCK file in Android project, in two places, and correspondingly adjust hierarchy in android project, although it is not necessary:

BUCK file:

 android_build_config(
     name = "build_config",
     package = "app.new.name",
 )

 android_resource(
     name = "res",
     package = "app.new.name",
     res = "src/main/res",
 )

run command ./gradlew clean

like image 161
big-toni Avatar answered Nov 27 '22 11:11

big-toni