Close out any development servers that you have running (you can list all terminal processes with the ps command, and search for Expo CLI or React Native community CLI processes with ps -A | grep "expo\|react-native" ). If this is a managed workflow project, either remove the sdkVersion field from your app.
We're abandoning native development for iOS and Android in front of newer technologies that allow us to create cross-platform mobile apps. I believe that 2021 will be a great year for React Native, as the library attracts more developers.
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.
In case you created your react-native app using create-react-native-app. You should have a app.json (expo). and a package.json file, check if the expo versions match and change accordingly. For example in my case the problem was that in the app.json file I had a 25.0.0 version for the expo sdkVersion attribute, I change that to 23.0.0 and everything worked.
package.json:
"dependencies": {
"expo": "^23.0.4",
"react": "16.0.0",
"react-native": "^0.50.4"
}
app.json:
{
"expo": {
"sdkVersion": "23.0.0" // before was 25.0.0
}
}
Just go to your android/app/build.gradle
and then add to the dependencies
section:
dependencies{
compile ("com.facebook.react:react-native:0.50.3") { force = true }
}
/// the react native version can be found in package.json
For Android developers who couldn't get it fixed by just closing and rebuilding, Manually uninstall the app on the emulator/device.
just force react native version in your android's app level gradle file, in the dependencies
section.
compile ("com.facebook.react:react-native:0.52.0") { force = true }
worked for me
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With