mllm mllm - 24 days ago 15
Android Question

Change package name for Android in React Native

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
.

What's the best way to change this package name, for example to:
com.mycompany.myapp
?

I tried changing it in
AndroidManifest.xml
but it created other errors, so I'm assuming it's not the way.

Any idea?

Answer

I've manually changed it in android/app/src/main/java/com/PROJECT_NAME/MainActivity.java:

package MY.APP.ID;

In android/app/src/main/java/com/PROJECT_NAME/MainApplication.java:

package MY.APP.ID;

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

package="MY.APP.ID"

And in android/app/build.gradle:

applicationId "MY.APP.ID"

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

./gradlew clean
Comments