首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >反应本机0.61.3 android -不能更改应用程序id

反应本机0.61.3 android -不能更改应用程序id
EN

Stack Overflow用户
提问于 2019-10-30 15:44:51
回答 2查看 615关注 0票数 0

我正在用一个新的npx react-native init将rn项目从0.59迁移到0.61.3 (最新)。

我需要更改它提供给android应用程序的defaut应用程序id。为了做到这一点,我做到了:

package="mycomp.myapp"

  • change

  • manifest.xml中的package="com.myapp"值更改为manifest.xml中的package="com.myapp"值,将manifest.xml中的applicationId "com.myapp"值更改为applicationId "mycomp.myapp",src包com/myapp/MainApplication中的package="com.myapp"值更改为mycomp/myapp/MainApplication

  • change,这是在_BUCK文件中进行的(不确定它到底是什么.):

android_build_config( name = "build_config",package = "mycomp.myapp",) android_resource( name = " res ",package = "mycomp.myapp",res= "src/main/res",)

在此之后,即使在./gradlew clean成功运行之后,当运行npx react-native run-android命令时,应用程序也会安装但崩溃时:

代码语言:javascript
复制
2019-10-30 15:43:26.978 30576-30743/mycomp.myapp E/AndroidRuntime: FATAL EXCEPTION: create_react_context
    Process: mycomp.myapp, PID: 30576
    java.lang.RuntimeException: Unable to load script. Make sure you're either running a Metro server (run 'react-native start') or that your bundle 'index.android.bundle' is packaged correctly for release.
        at com.facebook.react.bridge.CatalystInstanceImpl.jniLoadScriptFromAssets(Native Method)
        at com.facebook.react.bridge.CatalystInstanceImpl.loadScriptFromAssets(CatalystInstanceImpl.java:227)
        at com.facebook.react.bridge.JSBundleLoader$1.loadScript(JSBundleLoader.java:28)
        at com.facebook.react.bridge.CatalystInstanceImpl.runJSBundle(CatalystInstanceImpl.java:261)
        at com.facebook.react.ReactInstanceManager.createReactContext(ReactInstanceManager.java:1175)
        at com.facebook.react.ReactInstanceManager.access$1000(ReactInstanceManager.java:125)
        at com.facebook.react.ReactInstanceManager$5.run(ReactInstanceManager.java:951)
        at java.lang.Thread.run(Thread.java:764)

我们还看到Metro已启动并侦听,但调试应用程序从未达到此目的:

代码语言:javascript
复制
warn The following packages use deprecated "rnpm" config that will stop working from next release:
- react-native-orientation: https://github.com/yamill/react-native-orientation#readme
- react-native-push-notification: https://npmjs.com/package/react-native-push-notification
- react-native-sentry: https://github.com/getsentry/react-native-sentry
Please notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.
┌──────────────────────────────────────────────────────────────────────────────┐
│                                                                              │
│  Running Metro Bundler on port 8081.                                         │
│                                                                              │
│  Keep Metro running while developing on any JS projects. Feel free to        │
│  close this tab and run your own Metro instance if you prefer.               │
│                                                                              │
│  https://github.com/facebook/react-native                                    │
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘

Looking for JS files in
/Users/thomasfetiveau/wksp_myapp/myapp-rn61/bin
/Users/thomasfetiveau/wksp_myapp/myapp-rn61 

Loading dependency graph, done.

知道为什么吗?

在我的npx react-native info输出下面可以找到:

代码语言:javascript
复制
$ npx react-native info
warn The following packages use deprecated "rnpm" config that will stop working from next release:
- react-native-orientation: https://github.com/yamill/react-native-orientation#readme
- react-native-push-notification: https://npmjs.com/package/react-native-push-notification
- react-native-sentry: https://github.com/getsentry/react-native-sentry
Please notify their maintainers about it. You can find more details at https://github.com/react-native-community/cli/blob/master/docs/configuration.md#migration-guide.
info Fetching system and libraries information...
System:
    OS: macOS Mojave 10.14.5
    CPU: (4) x64 Intel(R) Core(TM) i7-7567U CPU @ 3.50GHz
    Memory: 78.62 MB / 16.00 GB
    Shell: 3.2.57 - /bin/bash
Binaries:
    Node: 8.11.3 - ~/.nvm/versions/node/v8.11.3/bin/node
    Yarn: 1.10.1 - /usr/local/bin/yarn
    npm: 5.6.0 - ~/.nvm/versions/node/v8.11.3/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
    iOS SDK:
    Platforms: iOS 13.0, DriverKit 19.0, macOS 10.15, tvOS 13.0, watchOS 6.0
    Android SDK:
    API Levels: 18, 23, 24, 25, 26, 27, 28, 29
    Build Tools: 23.0.1, 23.0.3, 25.0.0, 25.0.2, 25.0.3, 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.3, 29.0.2
    System Images: a...google_apis | Google APIs Intel x86 Atom Sys..., a...google_apis | Google APIs Intel x86 Atom Sys..., a... | Intel x86 Atom_64, a...google_apis | Google APIs Intel x86 Atom Sys..., a...gle_apis | Google APIs Intel x86 Atom_64 ..., a...-28 | Intel x86 Atom, a... | Intel x86 Atom_64, a...google_apis | Google APIs Intel x86 Atom Sys..., a...-29 | Intel x86 Atom, a... | Intel x86 Atom_64, a...google_apis | Google APIs Intel x86 Atom Sys...
IDEs:
    Android Studio: 3.5 AI-191.8026.42.35.5900203
    Xcode: 11.0/11A420a - /usr/bin/xcodebuild
npmPackages:
    react: ^16.11.0 => 16.11.0 
    react-native: 0.61.3 => 0.61.3 
npmGlobalPackages:
    create-react-native-module: 0.11.1
    react-native-create-library: 3.1.2
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-11-01 16:40:45

我所经历的问题并不是因为应用程序id的改变。这是由于使用了react本机导航+错误的java文件导入:https://github.com/wix/react-native-navigation/issues/5617

票数 0
EN

Stack Overflow用户

发布于 2019-10-30 16:06:53

请跑

代码语言:javascript
复制
adb reverse tcp:8081 tcp:8081

然后重新加载应用程序

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58629077

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档