I insert java_home in environment correctly and test it in cmd. I am connecting to the internet with the proxy and can download react-native packages. adb devices run correctly on cmd, but when running "react-native run-android" command I give below error:
D:\amoz\react-native\1\pro\test>react-native run-android
Scanning folders for symlinks in D:\amoz\react-
native\1\pro\test\node_modules (8
7ms)
Starting JS server...
Building and installing the app on the device (cd android && gradlew.bat
install
Debug)...
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by
org.gradle.internal.reflect.JavaMethod (fi
le:/C:/Users/01/.gradle/wrapper/dists/gradle-3.5.1-
all/42vjebfdws9pjts3l4bouoq0p
/gradle-3.5.1/lib/gradle-base-services-3.5.1.jar) to method
java.lang.ClassLoade
r.getPackages()
WARNING: Please consider reporting this to the maintainers of
org.gradle.interna
l.reflect.JavaMethod
WARNING: Use --illegal-access=warn to enable warnings of further illegal
reflect
ive access operations
WARNING: All illegal access operations will be denied in a future
release
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'test'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not resolve com.android.tools.build:gradle:2.3.3.
Required by:
project :
> Could not resolve com.android.tools.build:gradle:2.3.3.
> Could not get resource 'https://jcenter.bintray.com/com/android/tools
/build/gradle/2.3.3/gradle-2.3.3.pom'.
> Could not GET 'https://jcenter.bintray.com/com/android/tools/build
/gradle/2.3.3/gradle-2.3.3.pom'.
> Connect to jcenter.bintray.com:443 [jcenter.bintray.com/108.168
.243.150] failed: Connection timed out: connect
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.
BUILD FAILED
Total time: 26.739 secs
Could not install the app on the device, read the error above for
details.
Make sure you have an Android emulator running or a device connected and
have
set up your Android development environment:
https://facebook.github.io/react-native/docs/getting-started.html
Even I add Google() to build.gradle in allprojects{} It doesn't work again. and still giving that error. By the way, I am using JDK version 9 and gradle version 2.3.3
Unfortunately, Jcenter blocks requests from Iran due to US sanctions. You can use Hotspot Shield to connect to Jcenter, other VPN's providers may not work correctly. and i suggest you to update your gradle by this changes:
1- change gradle version to
classpath 'com.android.tools.build:gradle:3.1.1'
inandroid/build.gradle
2- change distributionUrl from
android/gradle/wrapper/gradle-wrapper.properties
todistributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
3- add repository to
android/build.gradle
like this:4- start Hotspot Shield and build project.
I hope this may help you.