Javascript 反应本机版本不匹配-本机版本:0.59.5

Javascript 反应本机版本不匹配-本机版本:0.59.5,javascript,android,react-native,Javascript,Android,React Native,我在Android模拟器上遇到此错误: 反应本机版本不匹配: Javascript版本:0.58.5 本机版本:0.59.5 我已经升级了React Native、模块、Android studio和几乎所有我能升级的东西。在iOS上一切正常,这只发生在Android上。构建是成功的 Package.json { "name": "MyProject", "version": "0.0.1", "private": true, "scripts": { "start":

我在Android模拟器上遇到此错误:

反应本机版本不匹配: Javascript版本:0.58.5 本机版本:0.59.5

我已经升级了React Native、模块、Android studio和几乎所有我能升级的东西。在iOS上一切正常,这只发生在Android上。构建是成功的

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-community/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"
  }
}
"react": "16.8.6",
"react-native": "0.60.4",
"react-native-maps": "0.25.0",
格雷德尔先生

buildscript {
    ext {
        buildToolsVersion = "28.0.3"
        minSdkVersion = 16
        compileSdkVersion = 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 'com.android.tools.build:gradle:3.3.0'
        classpath 'com.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 "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
        implementation "com.facebook.react:react-native:+"  // From node_modules
        implementation project(':react-native-linear-gradient')
        implementation project(':react-native-maps') 
        implementation "com.google.android.gms:play-services-base:16.0.1"
        implementation project(':@react-native-community_async-storage')

        implementation ("com.google.firebase:firebase-core:16.0.7") {
            exclude group: 'com.google.android.gms'
        } 

        implementation ("com.google.firebase:firebase-auth:16.1.0") {
            exclude group: 'com.google.android.gms'
        } 

        implementation ("com.google.firebase:firebase-database:16.0.6") {
            exclude group: 'com.google.android.gms'
        }
    }
我尝试关闭所有终端,安装纱线,创建新的安卓设备。我猜这与Package.json中React本机的实际版本有关,但它是0.59.5,当我搜索整个项目时,我在任何地方都找不到0.58.5的任何引用

谢谢
Luke

确保您在
package.json
中有与
android/app/build.gradle
中相同的RN版本,它应该如下所示:

在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-community/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"
  }
}
"react": "16.8.6",
"react-native": "0.60.4",
"react-native-maps": "0.25.0",
“react native”:“0.59.5”,

在android/app/build.gradle中

implementation(“com.facebook.react:react native:0.59.5”){force=true
}

编辑: 您是否可以检查打包机和仿真器/设备是否在同一网络中,以及JS捆绑包是否从正确的位置获取? 您的应用程序在构建时似乎没有得到更新,它被困在旧代码中


希望这有帮助。快乐编码

我在github论坛的帮助下解决了这个问题。在我的例子中,这个错误是由在模拟器中使用Android 9引起的。使用Android版本8安装新设备修复了此问题。

尝试以下操作:

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-community/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"
  }
}
"react": "16.8.6",
"react-native": "0.60.4",
"react-native-maps": "0.25.0",
build.gradle:

googlePlayServicesVersion = "15.0.1" 
 androidMapsUtilsVersion = "0.5+"

关闭所有终端和IDE,然后再次启动。它将工作

我从另一个使用旧RN的分支的上一个构建中得到了
workdir/android/app/src/main/assets/index.android.bundle


运行
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
为我修复了它。

在运行
之前,你能尝试删除
节点模块
文件夹和
包锁.json
文件吗安装
?关闭终端并再次运行。它正在工作。只需关闭emulator上的应用程序,然后从expo ui重新运行即可。@kenmistry如果要删除node_modules文件夹,是否需要重新安装所有模块?我是说第一次安装包时的所有设置?您能确保您使用的React-Native节点模块的package.json中的版本正确吗?我已经查看了React-Native节点模块中的package.json,它似乎是正确的:{“name”:“React-Native”,“version”:“0.59.5”,我在答案中添加了一个编辑部分。检查是否有帮助。@SurajMalviya如何检查打包程序和仿真器是否在同一个网络中?如何从正确的位置获取JS捆绑包?类似的解决方案,根据android设备工具创建一个新设备,并使用推荐的更新版本,这对我也很有用。@OsoGrizz您能告诉我吗请澄清您正在使用的设备和版本?我尝试将Pixel2 API 29与Android 9+(JS 0.58.5,NV 0.59.5)一起使用,但仍然会引发不匹配错误。因此,我仍然被迫使用模拟器Android 8.1,在那里工作正常。我无法确定之前使用的配置,但我现在使用的是Pixel 3 XL API 28 Android 9.0(谷歌API的),反应本机:0.59。8@CosmicSeizure面对一些类似的问题,我很好奇:你说的API 29/Android 9+是什么意思?就单个设备的操作系统而言,API 29意味着Android 10.0,而Android 9.0将等同于API 28,对吗?