更改Package Name(Bundle ID)

React native 預設的檔名為Package Name (Bundle Identifier)為

org.reactjs.native.example.projectName (ios) 及 com.ProjectName (Android)

可是我們常用的改名方式應為:com.companyName.projectName

因此有改名的必要


iOS

iOS較簡單,只需在xCode內切換到 App 的 General 頁面,把Identifier中的Bundle Identifier改為com.companyName.projectName就可。


Android

1.修改Folder位置

把Folder由 "android/app/src/main/java/com/ProjectName/"

改為

"android/app/src/main/java/com/companyName/projectName/"

2.修改下列檔案

android/app/src/main/java/com/companyName/projectName/MainActivity.java:

package com.companyName.projectName;

android/app/src/main/java/com/companyName/projectName/MainApplication.java:

package com.companyName.projectName;

android/app/src/main/AndroidManifest.xml:

package="com.companyName.projectName"

android/app/build.gradle:

applicationId  "com.companyName.projectName"

3. 執行Gradle' cleaning

最後/android folder下用Terminal 執行Gradle' cleaning

./gradlew clean

results matching ""

    No results matching ""