react-native modifies the package name of the android class

Android has the package name as the unique id of the application. Compared with iOS, it is not so convenient to change it, but in order to officially release your own application, you still have to change it.

Assuming the package name is com.exease.etd.objective, the following places need to be modified.

The first is two java files: android/app/src/main/java/com/PROJECT_NAME/MainActivity.java and /MainApplication.java, modify the first line of package com.exease.etd.objective;
then the Android description file android /app/src/main/AndroidManifest.xml, the second line changes the package to com.exease.etd.objective
, followed by two packaging scripts.
android/app/BUCK, modify the value of the two packages package = 'com.exease.etd.objective',
the applicationID in android/app/build.gradle is changed to applicationId "com.exease.etd.objective" After the
modification is completed , enter the android directory from the command line, and execute ./gradlew clean to clear the cache (gradlew.bat on windows).

At this point, the modification is almost completed, and the apk with the correct package name can be packaged. However, during the development process, if you need to automatically link the native module, it will cause a command error and fail to link successfully. Therefore, it is recommended to put the java file in the directory with the package name matching according to the java specification.
Move the two files android/app/src/main/java/com/PROJECT_NAME/MainActivity.java and /MainApplication.java into the newly created directory android/app/src/main/java/com/exease/etd/objective/ , you can happily react-native link.

Author: Layman_Layman
Link : http://www.jianshu.com/p/8b7412bab029
Source: Jianshu The
copyright belongs to the author. For commercial reprints, please contact the author for authorization, and for non-commercial reprints, please indicate the source.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326145259&siteId=291194637