6

I just installed a new version of Android Studio and am trying to create a project using the built in templates.

My environment is: Windows 7, SP1, 64 bit In a secure domain environment and I am a domain administrator on my machine.

Here is what I am seeing:

C:\Users\stuz\AndroidStudioProjects\test>gradlew compileDebug --stacktrace
Downloading file://C:/Users/stuz/.gradle/wrapper/dists/gradle-1.10-all.zip
Exception in thread "main" java.lang.RuntimeException: java.net.UnknownHostExcep
tion: C
        at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAcc
essManager.java:78)
        at org.gradle.wrapper.Install.createDist(Install.java:47)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: java.net.UnknownHostException: C
        at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
        at java.net.PlainSocketImpl.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at java.net.Socket.connect(Unknown Source)
        at sun.net.ftp.impl.FtpClient.doConnect(Unknown Source)
        at sun.net.ftp.impl.FtpClient.tryConnect(Unknown Source)
        at sun.net.ftp.impl.FtpClient.connect(Unknown Source)
        at sun.net.ftp.impl.FtpClient.connect(Unknown Source)
        at sun.net.www.protocol.ftp.FtpURLConnection.connect(Unknown Source)
        at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(Unknown Sour
ce)
        at org.gradle.wrapper.Download.downloadInternal(Download.java:59)
        at org.gradle.wrapper.Download.download(Download.java:45)
        at org.gradle.wrapper.Install$1.call(Install.java:60)
        at org.gradle.wrapper.Install$1.call(Install.java:47)
        at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAcc
essManager.java:65)
Zoe
  • 27,060
  • 21
  • 118
  • 148
StuZ
  • 61
  • 1
  • 1
  • 2
  • Looks like it's trying to ftp from "host" 'C' in file URL C:/Users/stuz/.gradle/wrapper/dists/gradle-1.10-all.zip. That's not going to end well. – mharper Apr 01 '14 at 20:56
  • I don't know if that's the problem, but local file URLs start with a triple-slash. Also don't forget to escape the colons in the properties file. Besides, I'm not sure why you would use a URL that points to `gradlew`'s own download directory, and whether this would work. – Peter Niederwieser Apr 02 '14 at 04:26

6 Answers6

1

The problem is in your gradle/wrapper/gradle_wrapper.properties file. I'm not sure how it happened, but you have an improper URL in there for the downloadable distribution of Gradle. Change that line from this:

distributionUrl=file://C:/Users/stuz/.gradle/wrapper/dists/gradle-1.10-all.zip

to this:

distributionUrl=http\://services.gradle.org/distributions/gradle-1.10-all.zip
Scott Barta
  • 79,344
  • 24
  • 180
  • 163
1

This solution worked for me...

Find the file gradlew.bat on your project directory, in that file change DEFAULT_JVM_OPTS variable as below:

set DEFAULT_JVM_OPTS=-Dhttp.proxyHost=YOUR_HOST -Dhttp.proxyPort=PORT -Dhttp.proxyUser=USERNAME -Dhttp.proxyPassword=PASSWORD -Dhttps.proxyHost=YOUR_HOST -Dhttps.proxyPort=PORT -Dhttps.proxyUser=USERNAME -Dhttps.proxyPassword=PASSWORD

then run gradlew clean build.

Deepak Kumrawat
  • 684
  • 1
  • 9
  • 14
0

Check if you are on secure network - if that is the case than in your gradle/wrapper/gradle_wrapper.properties file

distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip

this line have https in it which is refused by secure network. I changed to unsecure network and it started working for me.

Manisha
  • 813
  • 13
  • 24
0

under you project folder go to : platforms/android/cordova/lib/builders/GradleBuilder.js find distributionUrl and Remove https with http and replace "services" with "downloads".

distributionUrl=http\://downloads.gradle.org/distributions/gradle-2.4-all.zip
Mohit
  • 31
  • 5
-1

you need to use the windows style file URI to make it valid

Windows Reference for File URI

distributionUrl=file\:///C\:/Users/<your_path_separated_by_/_chars>/gradle-2.4-all.zip
Deepak
  • 1
-1

After changing the distribution url to http://services.gradle.org/distributions/gradle-1.10-all.zip .

If you still get unknown host exception for services.gradle.org, try setting the HTTP / HTTPS proxy to your environmental variables . See the below post

https://stackoverflow.com/a/59045565/4468693

Deepa
  • 14
  • 2