Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception in thread "main" java.net.UnknownHostException: services.gradle.org

I am getting the below error when executing gradle.bat. I have checked the URL path and it looks fine. The URL is defined like this in the wrapper properties:

distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-bin.zip 

Here's the error message:

Downloading https://services.gradle.org/distributions/gradle-2.1-bin.zip
Exception in thread "main" java.net.UnknownHostException: services.gradle.org at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:195)

Could someone help me on this?

like image 636
geetha Avatar asked Jul 01 '15 04:07

geetha


4 Answers

  1. Go to "C:\Users\[yourusername]\.gradle\" folder (hidden folder - Go to folder option and enable show hidden files if folder is not showing up)

  2. Look for file "gradle.properties" if DOES NOT (most likely this would be the case) exists, Create it under "C:\Users\[yourusername]\.gradle\

  3. Copy and paste following code (More detail ... https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties ... look for "20.3 Accessing the web via proxy" for https and user/pwd variables)

systemProp.http.proxyHost=[PROXY SERVER] systemProp.http.proxyPort=[PROXY PORT]

  1. save and try again
like image 78
Chintan Desai Avatar answered Nov 20 '22 11:11

Chintan Desai


look for gradle.properties file open it and change from 'distributionUrl=https\' to 'distributionUrl=http\' that will fix it.

like image 32
Med. A. Avatar answered Nov 20 '22 09:11

Med. A.


I was facing the same problem when I was connected to WiFi with a download speed of 80 Mbps which is good enough, I guess. After spending hours while still being clueless, I just changed the network. Connected to hotspot from my mobile data with a much lower download speed of around 4 Mbps. The error vanished! Maybe something was wrong with the WiFi.

like image 6
Chirag Mittal Avatar answered Nov 20 '22 10:11

Chirag Mittal


1) Go to your project directory

2) Find below file on your project directory:

gradlew
gradlew.bat

3) Edit gradlew file and change DEFAULT_JVM_OPTS variable value as below:

DEFAULT_JVM_OPTS="-Dhttp.proxyHost=XXXX -Dhttp.proxyPort=XXXX -Dhttp.proxyUser=XXXX -Dhttp.proxyPassword=XXXX  -Dhttps.proxyHost=XXXX -Dhttps.proxyPort=XXXX -Dhttps.proxyUser=XXXX-Dhttps.proxyPassword=XXXX"

save it.

4) Edit gradlew.bat file and change DEFAULT_JVM_OPTS variable value as below:

set DEFAULT_JVM_OPTS=-Dhttp.proxyHost=XXXX -Dhttp.proxyPort=XXXX -Dhttp.proxyUser=XXXX -Dhttp.proxyPassword=XXXX  -Dhttps.proxyHost=XXXX -Dhttps.proxyPort=XXXX -Dhttps.proxyUser=XXXX-Dhttps.proxyPassword=XXXX

save it.

5) Now run your "gradlew clean build" and check.

Please set your appropriate value on the place of XXXX

Note: gradlew is use for linux system user and gradlew.bat is user for window system user

like image 5
Piyush Chaudhari Avatar answered Nov 20 '22 10:11

Piyush Chaudhari