Sam Rao
Sam Rao

Reputation: 4571

React Native version mismatch

Getting the following message when I init a new project and then launch the Xcode emulator:

React-Native Version Mismatch

Javascript Version 0.50.1 Native version: 0.50.0

Make sure you have rebuilt the native code. ...

Does anyone know what is going on here and can help me?

Upvotes: 277

Views: 222466

Answers (30)

Zishan Ali
Zishan Ali

Reputation: 59

You may forget to close metro bundler and running another project. so try to close all terminal window and then run the metro bundler from correct folder/directory. it should work.

Upvotes: 0

Paresh chavda
Paresh chavda

Reputation: 345

Close js Server terminals and run build again

Upvotes: 0

sigmapi13
sigmapi13

Reputation: 2553

Installing a new emulator and closing all terminals used to work for me and only when I ran from Android Studio. Now that's not working anymore.

A bit counterintuitive but I noticed that when I ran from Android Studio received that error the metro bundler terminal wasn't launching.

enter image description here

So I executed npx react-native run-android from terminal (which didn't work but it did launch the metro bundler) , then I ran that app from Android Studio and it worked!

enter image description here

Upvotes: 0

Quick learner
Quick learner

Reputation: 11477

For me, I had to open multiple node js terminal for react native and forgot to close before running app into my android device. I close the terminal and run again and it loaded the page successfully

Upvotes: -1

Daniel Danielecki
Daniel Danielecki

Reputation: 10590

I've had this issue after manually updating my packages. Removing all projects from the Expo Go app and running expo update fix the problem automatically for me.

Upvotes: 0

AliTN
AliTN

Reputation: 124

for my problem fix this when change emulator with API Level below 28. this source of problem because of network changes in API Level 28 and above. fix this problem by add

<application
     android:usesCleartextTraffic="true"

to androidManifest.xml

Upvotes: 1

Pushpendra Chouhan
Pushpendra Chouhan

Reputation: 42

Delete your application from your device and then install it again

Upvotes: 0

Rajitha Udayanga
Rajitha Udayanga

Reputation: 1742

I found an answer from stackoverflow another question and I like to place it here.

First step: I changed the value of expo in package.json file to the latest supported version, according to expo documents(visit here).

Second step: I changed the value of sdkVersion in app.json file to the same value of expo in package.json.( equal number to last step).

if sdkVersion not exists in your app.json file, please add it like this. "sdkVersion": "xx.x.x" (same as expo version in package.json)

Third step : I changed the value of react-native in package.json file to the same value of React Native Version , according to expo documents(visit here).

Upvotes: 0

Shreya B
Shreya B

Reputation: 326

This worked for me

expo update 39.0.0 --npm

As my expo version was 38(Check in package.json).

Upvotes: 0

vonGohren
vonGohren

Reputation: 949

For me, who is running with a monorepo, there was a hidden react-native version inside yarn.lock. It was not present in any package.json, but was never deleted.

I removed that particular react-native version from yarn.lock, and did a

yarn install

This cleaned out alot of old stuff and made sure that things was working fine.

Upvotes: 2

FMaz008
FMaz008

Reputation: 11295

All those answers about changing versions to match whatever were wrong for me.

What the error does not tell you is where that version is coming from. Running a search of all files, I found that there was only 1 place where the javascript version was defined: The problem was that the bundle (\android\app\src\main\assets\index.android.bundle) needed to be regenerated as it was containing older versions compared to the installed bundle.

In order to regenerate that file, I had to run the following command:

react-native bundle --platform android --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res

And because I had upgraded my react-native, running this command gave me a few errors I needed to resolve (mainly installing new dependencies).

Clearing cache, reloading in android studio, reloading react, reloading the terminal, creating a new project and transfering the files, running watchman, all did not work as that specific bundle file happens to be tracked in the Git repo.

Upvotes: 0

Ferhat KO&#199;ER
Ferhat KO&#199;ER

Reputation: 4075

edit your package.json for your javascript version

"react-native": "^0.50.1",

after run

npm install

Upvotes: 1

Kalyan Chakravarthy S
Kalyan Chakravarthy S

Reputation: 796

I updated the SDK version in app.json to match with the react native SDK version in package.json to fix this issue

In app.json

"sdkVersion": "37.0.0",

In package.json

"react-native": "https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz",

Upvotes: -1

Thomas Hagstr&#246;m
Thomas Hagstr&#246;m

Reputation: 4528

I got this classing when TypeScript type definitions mismatched.

E.G react-native at 0.61.5 in dependencies and @types/react-native at 0.60.0 in devDependencies.

As soon as I updated devDependencies it worked. Didn't have to restart anything.

Upvotes: 1

Parveen Chauhan
Parveen Chauhan

Reputation: 1496

This is working for me :

react-native start --reset-cache

Upvotes: 3

Saif Kamaal
Saif Kamaal

Reputation: 202

The fix we did was to make sure the ANDROID_HOME and PATH variables were set up prior to the build.

First, run the below two commands then the build the app for the device.

export ANDROID_HOME=/Users/username/MyFiles/applications/androidsdk
export PATH=$PATH:$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools

Upvotes: 3

Sina Abedi
Sina Abedi

Reputation: 2411

This Answer is Published in 2020, Fix this Error in 3 steps:

First step: I changed the value of expo in package.json file to the latest supported version, according to expo documents(visit here).

Second step: I changed the value of sdkVersion in app.json file to the same value of expo in package.json.( equal number to last step).

Third step : I changed the value of react-native in package.json file to the same value of React Native Version , according to expo documents(visit here).

now your ready to go.

use npm install to install specified version of dependencies and then npm start to run the project

Upvotes: 1

Giang Phan
Giang Phan

Reputation: 544

In my case, I changed the expo version manually. I got the same issue because I forgot to update sdkVersion in app.json and babel-preset-expo in package.json

After that run: expo r -c to clear cache and start the app.

Upvotes: 1

Ing Rico
Ing Rico

Reputation: 31

I update the react-native version: 0.57.4 to 0.59.8 and i getting the following message "React-Native Version Mismatch"

This solution works for me:

1.- In the folder of the project, update all the code react-native in the Android Studio:

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/

2.- Go to Android Studio and FILE->>INVALIDATE CACHES/RESTART
3.- In Android Studio, BUILD->>CLEAN PROJECT
4.- In Android Studio, BUILD->>REBUILD PROJECT
5.- Delete App in simulator or Devices
6.- Run...

I hope to help you!

Upvotes: 0

ketimaBU
ketimaBU

Reputation: 949

I have tried the solutions above but adding this to AndroidManifest.xml seems to fix it.

  android:usesCleartextTraffic="true"

Upvotes: 5

Dazzle
Dazzle

Reputation: 3083

I was able to fix this by deleting node_modules and running npm install again

Upvotes: 0

ade_anugerah
ade_anugerah

Reputation: 61

I am using a physical device, in my case this solved the problem:

  1. Uninstall the app
  2. lsof -i :8081
  3. kill -9 PID
  4. Rebuild the app (react-native run-android or react-native run-ios)

Upvotes: 6

Ashutosh Dash
Ashutosh Dash

Reputation: 610

Close the nodejs terminal and Rebuild.

Upvotes: 0

Val
Val

Reputation: 22807

This is what I've done with it:

Close all terminals and run build again.

You may forget to close nodejs terminal from another project, and they happen to have installed different react version.

So the code fetches from nodejs server conflicts with the native one.

Upvotes: 462

Isaac
Isaac

Reputation: 12894

For my case I'm facing it on iOS, and I've tried to reset and clear all cache using below command but failed too, despite many comments saying that the root cause is there is react packager running somewhere accidentally, I've restarted my mac and the problem still remained.

watchman watch-del-all && rm -rf node_modules/ && yarn cache clean && yarn install && yarn start --reset-cache

The solution is, to delete the build folder @ /ios/build, then execute react-native run-ios solved it

Upvotes: 4

civani mahida
civani mahida

Reputation: 342

It happens sometimes when you try to run without closing the node server, in which the previous app was running, so try restarting React.To do so, just run the following commands:

1. To kill current processes
killall node -9 

2. To Start React  Native
react-native start 

3. Then Run android
react-native run-android

Upvotes: 4

cherankrish
cherankrish

Reputation: 2120

Expo users - make sure your app.json sdk version and package.json expo version are (may be equal) compatible to each other.

Upvotes: 2

Siavas
Siavas

Reputation: 5090

This would be especially applicable for Android Studio 3.2 or newer users, as this did not seem to happen before upgrading.

If you didn't change the version of React Native in your configuration (package.json, build.gradle), the problem with the version mismatch could come from undetected changes to project files after checking out another commit in git. To overcome that, make sure to:

  • Clean the build: Build > Clean Project

  • Sync Project with Gradle files: next to the Stop button on navigation bar

  • Make Project: first button in navigation bar with an hammer icon

  • And finally Run / Debug app

This would also overcome the Session 'app': Error Installing APK error that might happen due to Instant Run once the app is uninstalled from the device.

Upvotes: 0

friederbluemle
friederbluemle

Reputation: 37203

I was trying to build and run a React Native app from WebStorm and ran into this problem. The simple solution for me was:

watchman watch-del-all

On macOS, if watchman is not already installed, install it using Homebrew:

brew install watchman

Upvotes: 1

Ajitsen
Ajitsen

Reputation: 348

In my case (NOT using expo & Android build)

package.json

"dependencies": {
    "react": "16.3.1",
    "react-native": "0.55.2"
}

And app.json

{
  "sdkVersion": "27"
}

resolved the issue

Upvotes: 1

Related Questions