简体   繁体   English

找不到变量:符号来自 <unknown> (仅限物理反应原生Android设备)

[英]Can't find variable: Symbol from <unknown> (on Physical React Native Android device only)

Running the newest version of RN, I get the below error. 运行最新版本的RN,我得到以下错误。 It only occurs however on a physical Android device (tried two different ones) - Android simulators and iOS are fine. 它只出现在物理Android设备上(试过两个不同的设备) - Android模拟器和iOS都很好。

Any ideas on whether this is some kind of caching issue (which I doubt based on all my clearing techniques) or a code error? 关于这是否是某种缓存问题(我怀疑基于我的所有清除技术)或代码错误的任何想法?

I have tried following advice on questions that are reasonably similar to this, but no luck. 我已经尝试过关于与此类似的问题的建议,但没有运气。

Worth noting that I have mobx installed which has caused this error message before, although it has always shown to come from there rather than showing unknown in the error's description. 值得注意的是我之前安装了mobx,导致此错误消息,尽管它总是显示来自那里,而不是在错误的描述中显示未知。

Many thanks! 非常感谢!

In Android Studio I get this error (unsure if the two are related): 在Android Studio中,我收到此错误(不确定两者是否相关):

E/ReactNativeJS: Can't find variable: Symbol E/ReactNativeJS: Module AppRegistry is not a registered callable module (calling runApplication) E / ReactNativeJS:找不到变量:符号E / ReactNativeJS:模块AppRegistry不是注册的可调用模块(调用runApplication)

React Native Error Screenshot: 反应原生错误截图:

错误截图

I was having trouble setting up mobx and mobx-react on my project, created using react-native init . 我在使用react-native init创建的项目上设置mobxmobx-react时遇到了麻烦。 I was having this very similar problem when running on my physical device, an Android Samsung J7 Pro. 在我的物理设备Android Android J7 Pro上运行时遇到了类似的问题。

At the end, it was about not installing mobx properly. 最后,它是关于不正确安装mobx

At first, I was getting the following black screen error: https://i.stack.imgur.com/ExSlC.png 起初,我收到以下黑屏错误: https//i.stack.imgur.com/ExSlC.png

Then after 1~2 seconds, this screen would turn to the following: https://i.stack.imgur.com/D74Ia.png 然后在1~2秒后,此屏幕将变为以下内容: https//i.stack.imgur.com/D74Ia.png

MobX >=5 is not supposed to run straight forward on React Native Android. MobX> = 5不应该在React Native Android上直接运行。 Then I just had to make sure to follow these steps to get it running: 然后我必须确保按照这些步骤运行它:

    1. brew install coreutils
    1. npm install jsc-android --save
    1. Follow this instructions (on Android Studio) 按照说明操作(在Android Studio上)
    1. Follow this troubleshooting. 请按照故障排除 (on Android Studio). (在Android Studio上)。 For me, it was complaining about a file called libjsc.so . 对我来说,它抱怨一个名为libjsc.so的文件。
    1. npm install --save-dev @babel/plugin-proposal-decorators
    1. change my babel.config.js file to the following content: 将我的babel.config.js文件更改为以下内容:
module.exports = {
  presets: ["module:metro-react-native-babel-preset"],
  "plugins": [
    ["@babel/plugin-proposal-decorators", { "legacy": true }],
    ["@babel/plugin-proposal-class-properties", { "loose": true }]
  ]
}

Here is my package.json file: 这是我的package.json文件:

{
  "name": "mobx_testing",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "jsc-android": "^236355.1.1",
    "mobx": "^5.9.0",
    "mobx-react": "^5.4.3",
    "react": "16.6.3",
    "react-native": "0.58.5"
  },
  "devDependencies": {
    "babel-core": "^7.0.0-bridge.0",
    "babel-jest": "24.1.0",
    "@babel/plugin-proposal-decorators": "^7.3.0",
    "jest": "24.1.0",
    "metro-react-native-babel-preset": "0.52.0",
    "react-test-renderer": "16.6.3"
  },
  "jest": {
    "preset": "react-native"
  }
}

Sometimes, .yarnclean makes error in my case. 有时, .yarnclean在我的案例中.yarnclean

If you have .yarnclean file, remove assets line or remove the file. 如果您有.yarnclean文件,请删除assets行或删除该文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM