Change package name for Android in React Native

后端 未结 20 1856
鱼传尺愫
鱼传尺愫 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 16:39

    If you are using Android Studio-

    changing com.myapp to com.mycompany.myapp

    1. create a new package hierarchy com.mycompany.myapp under android/app/src/main/java

    2. Copy all classes from com.myapp to com.mycompany.myapp using Android studio GUI

    3. Android studio will take care of putting suitable package name for all copied classes. This is useful if you have some custom modules and don't want to manually replace in all the .java files.

    4. Update android/app/src/main/AndroidManifest.xml and android/app/build.gradle (replace com.myapp to com.mycompany.myapp

    5. Sync the project (gradle build)

提交回复
热议问题