Android has a package name as the app's unique ID, which is not as easy to change as it is for iOS, but it has to be changed in order to be able to officially release its app.
Assuming the package name is com.exease.etd.objective
, the following needs to be modified.
- The first is two Java files: Android/app/src/main/java/com/project_name/mainactivity.java and/mainapplication.java, modifying the first behavior
package com.exease.etd.objective;
- Then the description file for Android Android/app/src/main/androidmanifest.xml, the second line to change the package to
com.exease.etd.objective
- Then there are two packaged scripts.
- Android/app/buck, modify the value of the two package
package = ‘com.exease.etd.objective‘,
- Android/app/build.gradle one of the ApplicationID, instead
applicationId "com.exease.etd.objective"
After the modification is complete, the command line enters the Android directory and performs ./gradlew clean
a clear cache (Gradlew.bat on Windows)
At this point it's almost done, and the APK with the correct package name can be packaged. However, in the development process, if the need for automatic link native module, will cause the command error cannot link success. It is recommended that Java files be placed in a directory matching the package name according to Java specifications.
Move the Android/app/src/main/java/com/project_name/mainactivity.java and/mainapplication.java two files into the newly created directory ANDROID/APP/SRC /main/java/com/exease/etd/objective/inside, you can happily react-native link.
Transferred from: http://www.jianshu.com/p/8b7412bab029
React-native Modifying the Android package name