React-native: React Native 0.58.X not running on Android Simulator nor Android Device

Created on 8 Feb 2019  路  8Comments  路  Source: facebook/react-native

馃悰 Bug Report

Hi! I have been banging my head against a wall for a while now with this one. As the title mentions, I am using React-Native 0.58.3 and when I try to run on any Android Simulator (regardless if I've installed the app on it before or not) I get a familiar error:

React native version mismatch.
JavaScript version: 0.56.1
Native versions: 0.58.3

So I tried everything the internet said to do...and more: blow out my node_modules, reset my watchman cache, confirm my build.gradle is forcing the react-native version, etc. I then started to clear the emulator cache, delete the emulator and create a new one, try it on another developer's machine, but to no avail.

Update: I now ran into this issue on a physical device (Samsung Galaxy S7, Version 6.0.1).

To Reproduce

Run react-native version 0.58.3 on an android simulator. Make sure you remove node modules and then reinstall them and restart your metro bundler.

Expected Behavior

The code works.

Environment

React Native Environment Info:
    System:
      OS: macOS 10.14.2
      CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
      Memory: 64.63 MB / 16.00 GB
      Shell: 5.3 - /bin/zsh
    Binaries:
      Node: 8.12.0 - ~/.nvm/versions/node/v8.12.0/bin/node
      Yarn: 1.12.3 - /usr/local/bin/yarn
      npm: 6.4.1 - ~/.nvm/versions/node/v8.12.0/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        API Levels: 23, 24, 25, 26, 27, 28
        Build Tools: 23.0.1, 26.0.3, 27.0.3, 28.0.3
        System Images: android-23 | Google APIs Intel x86 Atom, android-24 | Google APIs Intel x86 Atom, android-27 | Google Play Intel x86 Atom, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5056338
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      react: 16.6.3 => 16.6.3
      react-native: 0.58.3 => 0.58.3
    npmGlobalPackages:
      react-native-git-upgrade: 0.2.7
      react-native-log-ios: 1.0.0

image

Bug Android Locked

Most helpful comment

I think that the problem of being unable to connect to the packager is related to this PR:
https://github.com/facebook/react-native/pull/23135

I managed to fix the "could not connect to development server" problem by applying these changes:
https://github.com/matt-oakes/react-native/commit/fcd87eaa7f11e49c916453cd343b3fd2c6dfcf18#diff-000345b547ae9a4ea63fc5705b33fdca

All 8 comments

Same problem with 0.54.8, It's not loading the bundle from metro, It's loading from android/app/src/main/res/.
The version mismatch is because the android/app/src/main/res/*bundle.js* is old and not updated.

You could try react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/

But I think that It should be resolved.
It has happened on Linux, on OSX it's working.

I'm using OSX and facing it too but thanks for the recommendation! I'll give it a try now.

Update: Bundled the app with the above command (thanks to @dap1995) and was able to run on the simulator, but it doesn't solve the issue of being able to "communicate" with the metro bundler.

could you please check react-native version in package.json, and run yarn install.

I think that the problem is caused by a bug on react-native , cause the version mismatch is due an outdated bundle in android/app/src/main/res/. When running on android emulator, It doesn't make a request to metro bundler.

I think that the problem of being unable to connect to the packager is related to this PR:
https://github.com/facebook/react-native/pull/23135

I managed to fix the "could not connect to development server" problem by applying these changes:
https://github.com/matt-oakes/react-native/commit/fcd87eaa7f11e49c916453cd343b3fd2c6dfcf18#diff-000345b547ae9a4ea63fc5705b33fdca

So I added the network_security_config file and the lines to the AndroidManifest and so far it seems to work! I will re-open if I run into this issue again!

Hey guys, help me please. How do i remove safely the index.android.bundle to run from Metro Bundler? If i delete the ...bundle then RN shows 'index.android.bundle' error :(

@andresmtz98 Try this solution:
https://github.com/facebook/react-native/issues/16762#issuecomment-358527978

Was this page helpful?
0 / 5 - 0 ratings