Change Package Name for Android in React Native

Change package name for Android in React Native

I've renamed the project' subfolder from: "android/app/src/main/java/MY/APP/OLD_ID/" to: "android/app/src/main/java/MY/APP/NEW_ID/"

Then manually switched the old and new package ids:

In:
android/app/src/main/java/MY/APP/NEW_ID/MainActivity.java:

package MY.APP.NEW_ID;

In android/app/src/main/java/MY/APP/NEW_ID/MainApplication.java:

package MY.APP.NEW_ID;

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

package="MY.APP.NEW_ID"

And in android/app/build.gradle:

applicationId "MY.APP.NEW_ID"

In android/app/BUCK:

android_build_config(
package="MY.APP.NEW_ID"
)
android_resource(
package="MY.APP.NEW_ID"
)

Gradle' cleaning in the end (in /android folder):

./gradlew clean

Change package name and app name in react native

Are you referring to the app's name that'll be displayed on the phone?

For iOS, you can edit the name directly in XCode. See this answer.

For Android, you can edit the app name in strings.xml file located at android/app/src/main/res/values/strings.xml.

<string name="app_name">Your app's name</string>

Publishing android app error: You need to use a different package name because com.xxxx already exists in Google Play

You definitely need to assign a new/unique bundle identifier to your app. For that you will have to make changes to:

  • applicationId in (/android/app/build.gradle file)
  • package in (/android/app/src/main/AndroidManifest.xml)
  • and other files with Package ID

But I would suggest you to use the package react-native-rename which will safely update the App and Package name as well.

For firebase (google-services.json), you will need to configure another app with newly created bundle id and then attach the updated .json file to the project.

Change App Name In React Native

The generator does not override the strings.xml file located in android/app/src/main/res/values/, so you have to change the app_name variable manually

React Native: Error: Package name not found

If anybody encounters the same issue, when having multiple flavors and AndroidManifest.xml files,here`s my conclusion:
RN has some kind of a bug that it requires the first folder alphabetically, in android/app/src, which has AndroidManifest.xml file,to have the package attribute. Otherwise, it will throw an error.

A simple solution would be to create a dummy folder, e.g aaa (first alphabetically) and to create AndroidManifest.xml inside of it, with the following attribute - package:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="aaa"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission
android:name="android.permission.GET_ACCOUNTS"
tools:node="remove"/>
</manifest>


Related Topics



Leave a reply



Submit