ReactNative工程修改Android包名
預設初始化的React Native工程,生成Android工程的時候,包名預設是React Native工程的名字,跟一般Android工程com.company.xxx不一樣。
這時候就需要手動修改Android工程裡面的包名資訊:
如下:
首先修改React Native目錄下的MainActivity.java的包名,具體路徑是(android/app/src/main/java/com/PROJECT_NAME/MainActivity.java)
修改 package MY.COMPANY.APPID;
然後修改MainApplication.java的包名:具體路徑是(android/app/src/main/java/com/PROJECT_NAME/MainApplication.java)
修改 package MY.COMPANY.APPID;
然後修改AndroidManifest.xml裡面的包名,具體路徑是( android/app/src/main/AndroidManifest.xml)
修改 package = ”MY.COMPANY.APPID“
然後再修改build.gradle檔案,檔案路徑是(android/app/build.gradle)
applicationId "
MY.COMPANY.APPID
"
然後再clean整個工程即可,在路徑android檔案下執行如下命令:
./gradlew clean
然後執行 react-native run-android 即可。
如果遇見如下錯誤資訊:
PATIBLE: Package com.edaixi signatures do not match the previously installed version; ignoring! Unable to install /Volumes/CoderFile/react_delivery/ReactDelivery/android/app/build/outputs/apk/app-debug.apk com.android.ddmlib.InstallException: Failed to finalize session : INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.edaixi signatures do not match the previously installed version; ignoring! at com.android.ddmlib.Device.installPackages(Device.java:915) at com.android.builder.testing.ConnectedDevice.installPackages(ConnectedDevice.java:113) at com.android.builder.testing.ConnectedDevice$installPackages$0.call(Unknown Source) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128) at com.android.build.gradle.internal.tasks.InstallVariantTask.install(InstallVariantTask.groovy:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:226) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:219) at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:208) at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:589) at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:572) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46) at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:42) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) at org.gradle.api.internal.AbstractTask.executeWithoutThrowingTaskFailure(AbstractTask.java:310) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.executeTask(AbstractTaskPlanExecutor.java:79) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:63) at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:51) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:23) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:88) at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37) at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62) at org.gradle.execution.DefaultBuildExecuter.access$200(DefaultBuildExecuter.java:23) at org.gradle.execution.DefaultBuildExecuter$2.proceed(DefaultBuildExecuter.java:68) at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32) at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:62) at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:55) at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:149) at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106) at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86) at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:90) at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28) at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41) at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28) at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:50) at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:27) at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:40) at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:169) at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237) at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210) at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35) at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24) at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206) at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169) at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33) at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22) at org.gradle.launcher.Main.doAction(Main.java:33) at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54) at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35) at org.gradle.launcher.GradleMain.main(GradleMain.java:23) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30) at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:127) at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61) :app:installDebug FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task `:app:installDebug`. > com.android.builder.testing.api.DeviceException: com.android.ddmlib.InstallException: Failed to finalize session : INSTALL_FAILED_UPDATE_INCOMPATIBLE: Package com.edaixi signatures do not match the previously installed version; ignoring! * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. BUILD FAILED Total time: 1 mins 23.194 secs Could not install the app on the device, read the error above for details. Make sure you have an Android emulator running or a device connected and have set up your Android development environment: https://facebook.github.io/react-native/docs/android-setup.html
可能是已經安裝了與之衝突的相關應用,解除安裝相關應用,重新安裝即可解決.
相關文章
- Eclipse 如何快速修改工程名及包名Eclipse
- Android ant修改包名打包 (轉)Android
- Android Studio修改專案名和包名Android
- ReactNative打離線包-android篇ReactAndroid
- 修改Xcode工程名稱XCode
- Android 程式設計下如何修改 jar 檔案的包名Android程式設計JAR
- 如何更有效地修改Android程式的開發包名Android
- Android Studio 修改包名 com.example.calculator----->com.melon.calculatorAndroid
- 利用 ant 指令碼修改專案包名指令碼
- Android 多包名打包應用Android
- React-Native修改安卓平臺的包名React安卓
- React Native 修改Android工程目錄React NativeAndroid
- android 模擬器 記憶體修改, 用winshark 抓包,修改資料包Android記憶體
- ReactNative打離線包-ios篇ReactiOS
- Ant自動打包(可動態修改包名、資源等)生成不同簽字不同包名的APPAPP
- ReactNative呼叫Android原生模組ReactAndroid
- 簽名修改
- Android ReactNative資料互動AndroidReact
- Android動態修改應用圖示和名稱Android
- Android判斷當前棧頂Activity的包名Android
- 國內主要Android應用市場包名大全Android
- ReactNative專案打包(Android&&IOS)ReactAndroidiOS
- 批量修改檔名
- Eclipse project 重新命名問題(如何徹底修改Eclipse工程名)EclipseProject
- Flutter獲取IOS bundle id和Android應用包名FlutteriOSAndroid
- android 5.0以上獲取前臺應用的包名Android
- android 6.0下獲取當前呼叫介面的包名Android
- 【cocos2dx】改安裝包名、app名、圖示、包名APP
- java修改jar包JavaJAR
- Git修改檔名稱Git
- java批量修改檔名Java
- windows 修改例項名Windows
- sql server 修改表名SQLServer
- MAC修改主機名、計算機名Mac計算機
- 教你輕鬆修改ReactNative的埠(如何同時執行多個ReactNative、8081埠占用問題)React
- android檢視當前應用的的包名和activityAndroid
- Visual Studio 2017為Android APK包簽名AndroidAPK
- 快速批量修改檔名[機器學習]機器學習