Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change React Native Android project name

I need to change the name of my React Native Android project. I changed my app/src/main/AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.[new name here]">

but when I try to build a release apk I get the following error

:app:compileReleaseJavaWithJavac
/Users/harrymoreno/programming/contactsPro/android/app/src/main/java/com/contactspro/MainActivity.java:34: error: cannot find symbol
            .setUseDeveloperSupport(BuildConfig.DEBUG)
                                    ^
  symbol:   variable BuildConfig
  location: class MainActivity
1 error
:app:compileReleaseJavaWithJavac FAILED
like image 944
Harry Moreno Avatar asked Dec 05 '22 19:12

Harry Moreno


1 Answers

I solved this by searching through the entire project for instances of the old project name using ripgrep and replacing the string in some places (don't try the files listing strings). At least 4 files need to be edited in order to change app name.

  • android/app/src/main/AndroidManifest.xml
  • android/app/src/main/PATH/TO/JAVA/FILES/MainActivity.java
  • android/app/src/main/PATH/TO/JAVA/FILES/MainApplication.java
  • /android/app/build.gradle

for example in /android/app/build.gradle

android {
 buildToolsVersion "23.0.1"

 defaultConfig {
     applicationId "com.[change name]"
     minSdkVersion 16
     targetSdkVersion 22
     versionCode 2

/android/app/src/main/AndroidManifest.xml

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="com.[change name]">

/android/app/src/main/java/com/contactspro/MainActivity.java

package com.[change name];
like image 118
Harry Moreno Avatar answered Dec 08 '22 08:12

Harry Moreno