react-native: React Native version mismatch (on app that was working a couple of hours ago) - Android

We’ve been working on this React Native app for a fair amount of time. It was working fine even a few hours ago and it suddenly started to give this error. None of the usual solutions (reset cache, reboot terminal and machine) are working.

screen shot 2018-05-15 at 11 13 20 am

Environment

Environment: OS: macOS Sierra 10.12.6 Node: 8.11.1 Yarn: 1.5.1 npm: 5.6.0 Watchman: Not Found Xcode: Xcode 9.2 Build version 9C40b Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed) react: 16.2.0 => 16.2.0 react-native: 0.52.0 => 0.52.0

Steps to Reproduce

react-native init App --version 0.52.0 react-native run-android

Expected Behavior

App should work

Actual Behavior

App doesn’t work

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 13
  • Comments: 33 (1 by maintainers)

Most upvoted comments

I was also struggling with this. Somebody has added this https://bintray.com/weimob/maven/react-native/0.55.3 and it will break all React Native Android builds that specify jcenter() in project’s repositories. To avoid this issue, you should force React Native version in android/app/build.gradle file like this compile ("com.facebook.react:react-native:0.52.0") { force = true }. Change 0.52.0 to version you’re using.

@Dror-Bar Use compile("com.facebook.react:react-native:0.51.0") { force = true }

Instead of compile "com.facebook.react:react-native:0.51.0" { force = true }

SOS!! I just bought a cup of coffee, why punish me with this error. 😦

@Wiltzu Am I doing something wrong? For me it looks like this:

dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:+"  // From node_modules
}

Changed to this:

dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile "com.facebook.react:react-native:0.51.0" { force = true } // From node_modules
}

And I’m getting the following error:

Could not find method com.facebook.react:react-native:0.51.0()

EDIT: I forgot to add the brackets. This is working: Thank you!

dependencies {
    compile fileTree(dir: "libs", include: ["*.jar"])
    compile "com.android.support:appcompat-v7:23.0.1"
    compile ("com.facebook.react:react-native:0.51.0") { force = true } // From node_modules
}

Initializing in the latest version works. We are however currently unable to upgrade our app to the newest version. The problem though, we didn’t upgrade any packages nor did we reinstall any. It just suddenly broke.