最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - React Native version Mismatch - Native version: 0.59.5 - Stack Overflow

programmeradmin2浏览0评论

I am getting this error on Android simulator:

React Native version mismatch:
Javascript version: 0.58.5
Native version: 0.59.5

I have upgraded React Native, modules, Android studio and pretty much everything i could. Everything works fine on iOS, this happens only on Android. Build is succesful

Package.json

{
  "name": "MyProject",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "@react-native-munity/async-storage": "^1.3.3",
    "latlon-geohash": "^1.1.0",
    "react": "16.8.3",
    "react-native": "0.59.5",
    "react-native-firebase": "^5.2.3",
    "react-native-gesture-handler": "^1.0.16",
    "react-native-keyboard-aware-scroll-view": "^0.8.0",
    "react-native-linear-gradient": "^2.5.3",
    "react-native-maps": "^0.24.2",
    "react-native-vector-icons": "^6.4.2",
    "react-navigation": "^3.3.2",
    "react-redux": "^6.0.1",
    "redux": "^4.0.1"
  },
  "devDependencies": {
    "babel-core": "^7.0.0-bridge.0",
    "babel-jest": "24.1.0",
    "jest": "24.1.0",
    "metro-react-native-babel-preset": "0.52.0",
    "react-test-renderer": "16.6.3"
  },
  "jest": {
    "preset": "react-native"
  }
}

Build.gradle

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        pileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
        googlePlayServicesVersion = "15.0.1"
        androidMapsUtilsVersion = "0.5+"
    }
    repositories {
        google()
        //mavenLocal()        
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
    dependencies {
        classpath '.android.tools.build:gradle:3.3.0'
        classpath '.google.gms:google-services:4.2.0'
      
    }
}

allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

/*
task wrapper(type: Wrapper) {
    gradleVersion = '4.7'
    distributionUrl = distributionUrl.replace("bin", "all")
}*/





   dependencies {
        implementation project(':react-native-firebase')
        implementation project(':react-native-gesture-handler')
        implementation fileTree(dir: "libs", include: ["*.jar"])
        implementation ".android.support:apppat-v7:${rootProject.ext.supportLibVersion}"
        implementation ".facebook.react:react-native:+"  // From node_modules
        implementation project(':react-native-linear-gradient')
        implementation project(':react-native-maps') 
        implementation ".google.android.gms:play-services-base:16.0.1"
        implementation project(':@react-native-munity_async-storage')
    
        implementation (".google.firebase:firebase-core:16.0.7") {
            exclude group: '.google.android.gms'
        } 
    
        implementation (".google.firebase:firebase-auth:16.1.0") {
            exclude group: '.google.android.gms'
        } 
    
        implementation (".google.firebase:firebase-database:16.0.6") {
            exclude group: '.google.android.gms'
        }
    }

I have tried closing all terminals, yarn install, creating new android device. I am guessing it has to do with actual version of the React Native in Package.json, but it is the 0.59.5 and when I searched whole project I cant find any reference to 0.58.5 anywhere.

I am getting this error on Android simulator:

React Native version mismatch:
Javascript version: 0.58.5
Native version: 0.59.5

I have upgraded React Native, modules, Android studio and pretty much everything i could. Everything works fine on iOS, this happens only on Android. Build is succesful

Package.json

{
  "name": "MyProject",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node node_modules/react-native/local-cli/cli.js start",
    "test": "jest"
  },
  "dependencies": {
    "@react-native-munity/async-storage": "^1.3.3",
    "latlon-geohash": "^1.1.0",
    "react": "16.8.3",
    "react-native": "0.59.5",
    "react-native-firebase": "^5.2.3",
    "react-native-gesture-handler": "^1.0.16",
    "react-native-keyboard-aware-scroll-view": "^0.8.0",
    "react-native-linear-gradient": "^2.5.3",
    "react-native-maps": "^0.24.2",
    "react-native-vector-icons": "^6.4.2",
    "react-navigation": "^3.3.2",
    "react-redux": "^6.0.1",
    "redux": "^4.0.1"
  },
  "devDependencies": {
    "babel-core": "^7.0.0-bridge.0",
    "babel-jest": "24.1.0",
    "jest": "24.1.0",
    "metro-react-native-babel-preset": "0.52.0",
    "react-test-renderer": "16.6.3"
  },
  "jest": {
    "preset": "react-native"
  }
}

Build.gradle

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        pileSdkVersion = 28
        targetSdkVersion = 28
        supportLibVersion = "28.0.0"
        googlePlayServicesVersion = "15.0.1"
        androidMapsUtilsVersion = "0.5+"
    }
    repositories {
        google()
        //mavenLocal()        
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
    dependencies {
        classpath '.android.tools.build:gradle:3.3.0'
        classpath '.google.gms:google-services:4.2.0'
      
    }
}

allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}

/*
task wrapper(type: Wrapper) {
    gradleVersion = '4.7'
    distributionUrl = distributionUrl.replace("bin", "all")
}*/





   dependencies {
        implementation project(':react-native-firebase')
        implementation project(':react-native-gesture-handler')
        implementation fileTree(dir: "libs", include: ["*.jar"])
        implementation ".android.support:apppat-v7:${rootProject.ext.supportLibVersion}"
        implementation ".facebook.react:react-native:+"  // From node_modules
        implementation project(':react-native-linear-gradient')
        implementation project(':react-native-maps') 
        implementation ".google.android.gms:play-services-base:16.0.1"
        implementation project(':@react-native-munity_async-storage')
    
        implementation (".google.firebase:firebase-core:16.0.7") {
            exclude group: '.google.android.gms'
        } 
    
        implementation (".google.firebase:firebase-auth:16.1.0") {
            exclude group: '.google.android.gms'
        } 
    
        implementation (".google.firebase:firebase-database:16.0.6") {
            exclude group: '.google.android.gms'
        }
    }

I have tried closing all terminals, yarn install, creating new android device. I am guessing it has to do with actual version of the React Native in Package.json, but it is the 0.59.5 and when I searched whole project I cant find any reference to 0.58.5 anywhere.

Share Improve this question edited Oct 30, 2021 at 4:51 Nimantha 6,4866 gold badges31 silver badges76 bronze badges asked Apr 25, 2019 at 0:14 CosmicSeizureCosmicSeizure 1,5245 gold badges20 silver badges37 bronze badges 6
  • can you try removing node_modules folder and package-lock.json files before running yarn install? – kenmistry Commented Apr 25, 2019 at 1:47
  • 1 close your terminal and run again. it's working. – Kirit Modi Commented Apr 25, 2019 at 3:16
  • just close the app on the emulator and rerun it from expo ui. – Junius L Commented Apr 25, 2019 at 6:32
  • stackoverflow./questions/47763824/… – Kirankumar Dafda Commented Apr 25, 2019 at 9:05
  • @kenmistry if i will remove the node_modules folder, will i have to reinstall all the modules again ? I mean all the setup when doing first time installation of a package ? – CosmicSeizure Commented Apr 25, 2019 at 10:18
 |  Show 1 more ment

5 Answers 5

Reset to default 2

I fixed the problem with help from github forum. This error was caused in my case by having Android 9 in simulator. Installing new device with Android version 8 fixed the issue.

Close all terminal and IDE and Launch it again. It will work

Try following :

package.json

"react": "16.8.6",
"react-native": "0.60.4",
"react-native-maps": "0.25.0",

build.gradle :

googlePlayServicesVersion = "15.0.1" 
 androidMapsUtilsVersion = "0.5+"

I had workdir/android/app/src/main/assets/index.android.bundle left from the previous build from another branch where I used older RN.

Running react-native bundle --platform android --dev true --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res fixed it for me.

Make sure you have RN versions in package.json same as it is in android/app/build.gradle, it should look like:

in package.json

"react-native": "0.59.5",

and in android/app/build.gradle

implementation (".facebook.react:react-native:0.59.5") { force = true }

Edit: Can you please also check that the packager and the emulator/device are in same network and the JS bundle is fetched from right locations ? It seems your application is not getting updated while building, it is stuck in the old code.

发布评论

评论列表(0)

  1. 暂无评论