React-native Modifying the Android package name

Source: Internet
Author: User
Tags unique id

Android uses the package name as the unique ID for the app.

Assuming the package name is com.oc.objective, the following needs to be modified.

Two Java files
    • Android/app/src/main/java/com/project_name/mainactivity.java
    • Android/app/src/main/java/com/project_name/mainapplication.java

修改第一行

package com.oc.objective;
Description file for Android
    • Android/app/src/main/androidmanifest.xml

修改第二行,把package的至改为com.oc.objective

package="com.oc.objective"
Two pack Scripts 1. Android/app/buck

修改两个package的值package = ‘com.oc.objective‘

android_build_config(    ...    package = "com.oc.objective",)android_resource(    ...    package = "com.oc.objective",    ...)
Android/app/build.gradle

修改applicationID

defaultConfig {    applicationId "com.oc.objective"    ...}

After the modification is complete, the command line enters the Android directory and performs ./gradlew clean a clear cache (on Windows gradlew.bat )

Cannot link

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 two Java files into the newly created directory android/app/src/main/java/com/oc/objective/inside, you will be able to react-native link.

    • Android/app/src/main/java/com/project_name/mainactivity.java
    • Android/app/src/main/java/com/project_name/mainapplication.java

React-native Modifying the Android package name

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.