{
"name": "RNNProject",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.8.3",
"react-native": "0.59.1",
"react-native-navigation": "^2.15.0"
},
"devDependencies": {
"@babel/core": "7.4.0",
"@babel/runtime": "7.4.2",
"babel-jest": "24.5.0",
"jest": "24.5.0",
"metro-react-native-babel-preset": "0.53.1",
"react-test-renderer": "16.8.3"
},
"jest": {
"preset": "react-native"
}
}
graddle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
Build Graddle
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1' }
Asked
Active
Viewed 2.2k times
16
-
I guess React Native 0.59.0-rc.3 solved this issue. https://github.com/wix/react-native-navigation/issues/4757#issuecomment-468133753 – errorau Mar 22 '19 at 13:14
4 Answers
28
I resolved this issue by doing the following steps:
- in android/gradle/wrapper/gradle-wrapper.properties change
distributionUrl
value todistributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
. - in android/build.gradle change
classpath
to'com.android.tools.build:gradle:3.3.0'
. - *Optional (if using Metro) create metro.config.js in your project directory and put this code into it .
- *Optional (if using Metro) And make sure version of metro in package.json
"metro-react-native-babel-preset": "0.51.0"
is right in your packge.json file. - remove node_modules folder and run
yarn install
.

kingPuppy
- 2,937
- 1
- 18
- 18

Omar Al-Howeiti
- 1,227
- 7
- 19
-
1Also have this issue. By using gradle 3.3.0. There is a bug with gradle 3.3.0. It can not resolve the R file. So I can not build my project. I need to downgrade to gradle 3.2.1. Do you have any suggestion about this situation? – llch Mar 27 '19 at 10:05
-
1@llch are you using react-native or java? I'm not sure if there is a bug when you upgrade gradle but you can see this [https://stackoverflow.com/questions/885009/r-cannot-be-resolved-android-error] may help you. – Omar Al-Howeiti Mar 27 '19 at 10:47
-
These steps are not matched with wix documentations. These steps are caused new errors which is about junit test. – YigitB. Mar 27 '19 at 14:39
-
@Omar, I am using react-native. This is a react-native project, and there is native android view, which is written by Java. I added layout resources and custom java class in Android Studio to the whole project. – llch Mar 28 '19 at 03:17
-
I wonder instead of exact number what should be the general fix. I mean I have distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip and already followed this https://rnfirebase.io/docs/v5.x.x/installation/android and still getting similar error – Carmine Tambascia Aug 05 '19 at 12:28
3
This happens when you have react native version updated but your project code is not compatible with react native version.
So you need to do changes manually. You can do it by using react-native upgrade helper
https://react-native-community.github.io/upgrade-helper
Specify your current react-native version and the version would you like to update. You can see the changes that need to be done
Attaching screenshot for help

Ibtesam Latif
- 1,175
- 1
- 10
- 13
-
1
-
1@praveenseela your comment didn't help me either. Do you mind being more specific? – Odys Nov 21 '20 at 17:43
2
Resolved my issue by following these steps
- Remove
node_modules
andpackage-lock.json/yarn.lock
. - Set
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
ingradle-wrapper.properties
- Add classpath(
com.android.tools.build:gradle:3.4.0
) inandroid/build.gradle
underbuildscript.dependencies
. - Run
yarn
.
You may run into other errors due to gradle upgrade which needs to be resolved.

Ru Chern Chong
- 3,692
- 13
- 33
- 43

suresh babu
- 21
- 3
0
Extra to Omar Al-Howeiti's answer.
Add android:usesCleartextTraffic="true" to AndroidManifest.xml
<application
android:name=".MainApplication"
android:label="@string/app_name"
android:icon="@mipmap/ic_launcher"
android:allowBackup="false"
android:usesCleartextTraffic="true"
android:theme="@style/AppTheme">

Azimbek Makhmudov
- 1
- 1
- 1