Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. It only occurs however on a physical Android device (tried two different ones) - Android simulators and iOS are fine.

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.

Many thanks!

In Android Studio I get this error (unsure if the two are related):

E/ReactNativeJS: Can't find variable: Symbol E/ReactNativeJS: Module AppRegistry is not a registered callable module (calling runApplication)

React Native Error Screenshot:

Error screenshot

like image 833
hardanger Avatar asked Nov 07 '22 20:11

hardanger


1 Answers

I was having trouble setting up mobx and mobx-react on my project, created using react-native init. I was having this very similar problem when running on my physical device, an Android Samsung J7 Pro.

At the end, it was about not installing mobx properly.

At first, I was getting the following black screen error: 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

MobX >=5 is not supposed to run straight forward on 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)
    1. Follow this troubleshooting. (on Android Studio). For me, it was complaining about a file called libjsc.so.
    1. npm install --save-dev @babel/plugin-proposal-decorators
    1. change my babel.config.js file to the following content:
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:

{
  "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"
  }
}

like image 128
diogenesgg Avatar answered Nov 13 '22 03:11

diogenesgg