Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React Native version mismatch (on app that was working a couple of hours ago) - Android #19259

Closed
2 of 3 tasks
mthahzan opened this issue May 15, 2018 · 33 comments
Closed
2 of 3 tasks
Labels
Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.

Comments

@mthahzan
Copy link

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

@react-native-bot
Copy link
Collaborator

Thanks for posting this! It looks like your issue may refer to an older version of React Native. Can you reproduce the issue on the latest release, v0.55?

Thank you for your contributions.

@mthahzan
Copy link
Author

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.

@vksgautam1
Copy link

vksgautam1 commented May 15, 2018

same issue is happening with us. no changes done by us, it was working yesterday and today it is showing "React Native version mismatch "
Edit-:

  • i think for everyone it is showing same native version "0.55.3"

@Dror-Bar
Copy link

Dror-Bar commented May 15, 2018

Exact same thing here. I literally didn't touch the app, it was fully functional 2 days ago and now it's giving me this error.

screen shot 2018-05-15 at 9 41 15

@Yusiro85
Copy link

Yusiro85 commented May 15, 2018

Same thing happened to me. Didn't even open the app recently then now its giving me this error

@git-Asir
Copy link

same issue is happening with us. no changes done by us, it was working yesterday and today it is showing "
React Native version mismatch
JavaScript version:0.50.3
Native version:0.55.3 "
but my react-native -version is:
react-native-cli: 2.0.1
react-native: 0.50.3

@bluenex
Copy link

bluenex commented May 15, 2018

It's Android only issue, at least for me. What surprised me is that it is not even 15 minutes apart and I was still testing the working one, then this error occurs.

@favonianpine
Copy link

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

@syedtajudheen
Copy link

syedtajudheen commented May 15, 2018

facing same issue here :(
Any fix??

@roilandshut
Copy link

facing same issue :(((

@pkhien95
Copy link

What is happening? I didn't change anything

@Wiltzu
Copy link

Wiltzu commented May 15, 2018

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.

@cx5168
Copy link

cx5168 commented May 15, 2018

I have the same thing.
1

@Dror-Bar
Copy link

Dror-Bar commented May 15, 2018

@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
}

@mthahzan
Copy link
Author

Thanks @Wiltzu , that worked a charm

@kyo504
Copy link
Contributor

kyo504 commented May 15, 2018

I am also facing this issue. When building android, each package uses wrong version instead of the one specified in packages.json.

"source": "/Users/daniel/workspace/collabee-reactnative/node_modules/react-native-fcm/android/build/intermediates/exploded-aar/com.facebook.react/react-native/0.55.3/res/anim/catalyst_push_up_in.xml"

Anyone knows what's happening now?

@mthahzan
Copy link
Author

@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 }

@MatyasM12
Copy link

@Wiltzu 's comment fixed it for me, at least for now!

@gourav-singhal
Copy link

@bluenex same here worked for me around 2 hrs ago now causing same error as above.

@faizlo
Copy link

faizlo commented May 15, 2018

compile("com.facebook.react:react-native:0.51.0") { force = true } fixed it for me. For now.

@tobiaskusnaman
Copy link

@Wiltzu Thanks, it works for now

@chandralinapaul
Copy link

It's working now. go to app/build.gradel
compile("com.facebook.react:react-native:0.53.3") { force = true }
as per your react-native version

@Vigneshlakshminarayanan
Copy link

Vigneshlakshminarayanan commented May 15, 2018

@Wiltzu You are a legend man.! Thanks. That saved us.

@mthahzan Thank you for raising it in the right forum.

@cx5168
Copy link

cx5168 commented May 15, 2018

Thanks @Wiltzu!

@hanliangel
Copy link

Thanks @Wiltzu . it took me 4 hours

@luyuan11233
Copy link

Thanks @Wiltzu , it worked!

@WybornyWypiek
Copy link

@Wiltzu you made my day :)

@blastering66
Copy link

@Wiltzu Thank you.

btw how is this happened ?? and is this a temporary and how is this gonna effect on all of us ?

@MannyEC
Copy link

MannyEC commented May 15, 2018

Thanks @Wiltzu

@KirankumarDafda
Copy link

@Wiltzu after 4 hours of R&D your solution helped. But application was working fine till yesterday, what changes affect to the app of all the developers ?

@kelset
Copy link
Contributor

kelset commented May 15, 2018

As mentioned by @Wiltzu it seems that this issue surfaced when someone on maven 'upgraded' the react native dependency.
This means that you need to fix your dependency instead of just depending on "latest" (which is standard behaviour on Android when you don't explicitly say the version number - from my understanding).

I urge you all to properly set fixed version numbers on your gradle files (and also your package.json, and so on) for each dependency in order to avoid these kind of side effects.

Since the issue per se is "not an issue" and there is a workaround for those who are not on latest, I will limit the conversation to avoid spam waves of useless comments.

Again, I urge you to be particularly precise on your Android native configs, since Google is going to enforce some new patterns in terms of dependencies in the comings months - we will create an 'umbrella' issue to list all the changes that this repo will need in order to properly handle them.

@facebook facebook locked as resolved and limited conversation to collaborators May 15, 2018
@kelset
Copy link
Contributor

kelset commented May 15, 2018

Side note, regarding the 'why' this happens:

Once each repository has been inspected for the module, Gradle will choose the 'best' one to use. This is done using the following criteria:

For a dynamic version, a 'higher' concrete version is preferred over a 'lower' version.

Modules declared by a module metadata file (.module, .pom or ivy.xml file) are preferred over modules that have an artifact file only.

Modules from earlier repositories are preferred over modules in later repositories.

When the dependency is declared by a concrete version and a module metadata file is found in a repository, there is no need to continue searching later repositories and the remainder of the process is short-circuited.

Source: https://docs.gradle.org/current/userguide/introduction_dependency_management.html#sec:dependency_resolution

@kelset
Copy link
Contributor

kelset commented May 16, 2018

Closing, if you want to know more about how it got fixed you can read the explanation here

@kelset kelset closed this as completed May 16, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label May 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Platform: Android Android applications. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests