Change package name for Android in React Native

后端 未结 20 1837
鱼传尺愫
鱼传尺愫 2020-11-30 16:13

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.

20条回答
  •  清歌不尽
    2020-11-30 17:00

    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
    

提交回复
热议问题