Tuesday, October 31, 2017

Cannot build for android using react-native

Leave a Comment

I'm trying to run react-native run-android but I continuously get this error.I am running on emulator . I started the app using react-native init.

PS: I am running on proxy.

When I am trying to run

react-native run-android

I get:

FAILURE: Build failed with an exception.  *  What went wrong:  A problem occurred configuring root project 'AwesomeProject'.  > Could not resolve all dependencies for configuration ':classpath'.  > Could not resolve com.android.tools.build:gradle:2.2.3.  Required by:      :AwesomeProject:unspecified   > Could not resolve com.android.tools.build:gradle:2.2.3.      > Could not get resource 'https://jcenter.bintray.com/com/android/tool /build/gradle/2.2.3/gradle-2.2.3.pom'.         > Could not GET 'https://jcenter.bintray.com/com/android/tools/buil  /gradle/2.2.3/gradle-2.2.3.pom'. Received status code 407 from server:   Proxy Authentication Required 

When I am trying to run

directly in Android Studio

I get:

Error:Could not GET  'https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.3/gradle- 2.2.3.pom'. Received status code 407 from server: Proxy Authentication   Required <a href="toggle.offline.mode">Enable Gradle 'offline mode' and sync  project</a> 

I have my node_modules installed and I'm not sure what else to try, I've been googling for the last 4 hours and have come up with nothing.

4 Answers

Answers 1

your problem is not related to npm and node. you have some gradle problems.check if you can access the URL from browser?

https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.3/gradle- 2.2.3.pom

Answers 2

set your proxy details Inside sdk manager

AndroidStudio->tools->Android->SDKManager->system settings->Http Proxy

Answers 3

It clearly says <a href="toggle.offline.mode">Enable Gradle 'offline mode' and sync project</a>. Have you tried enabling offline mode? If not, try this:

Go to File -> Settings.

And open the 'Build,Execution,Deployment',Then open the 'Build Tools' -> 'Gradle'.

Then uncheck "Offline work" on the right.

Click the 'OK' button.

Then Rebuild the Project.

For Mac go to AndroidStudio -> Preferences, rest is same.

ref.: https://stackoverflow.com/a/30794890/2895571

Answers 4

Try adding these in your gradle.properties:

systemProp.http.proxyHost=proxyURL systemProp.http.proxyPort=proxyPort systemProp.http.proxyUser=USER systemProp.http.proxyPassword=PASSWORD systemProp.https.proxyHost=proxyUrl  systemProp.https.proxyPort=proxyPort systemProp.https.proxyUser=USER systemProp.https.proxyPassword=PASSWORD 
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment