I am trying to execute the phonegap build android command, but it is giving me an error. I need it to create an apk file to send push notifications to it. I have created a new project and when I execute the command I get the following error.
Downloading http://services.gradle.org/distributions/gradle-2.2.1-all.zip
Exception in thread "main" java.lang.RuntimeException: java.net.UnknownHostException: services.gradle.org
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.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: services.gradle.org
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184) at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:172) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at java.net.Socket.connect(Socket.java:538) at sun.net.NetworkClient.doConnect(NetworkClient.java:180) at sun.net.www.http.HttpClient.openServer(HttpClient.java:432) at sun.net.www.http.HttpClient.openServer(HttpClient.java:527) at sun.net.www.http.HttpClient.<init>(HttpClient.java:211) at sun.net.www.http.HttpClient.New(HttpClient.java:308) at sun.net.www.http.HttpClient.New(HttpClient.java:326) at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1168) at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1104) at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:998) at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:932) at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1512) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1440) 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(ExclusiveFileAccessManager.java:65) ... 3 more
C:\Users\anuraag\PhoneGapProjects\phonegapDemo\platforms\android\cordova\node_modules\q\q.js:126 throw e; ^ Error code 1 for command: cmd with args: /s /c "C:\Users\anuraag\PhoneGapProjects\phonegapDemo\platforms\android\gradlew cdvBuildDebug -b C:\Users\anuraag\PhoneGapProjects\phonegapDemo\platforms\android\build.gradle -Dorg.gradle.daemon=true"
Command finished with error code 1: cmd /s /c "C:\Users\anuraag\PhoneGapProjects\phonegapDemo\platforms\android\cordova\build.bat"
ERROR building one of the platforms: Error: cmd: Command failed with exit code 1 You may not have the required environment or OS to build this project
Error: cmd: Command failed with exit code 1 at ChildProcess.whenDone (C:\Users\anuraag\AppData\Roaming\npm\node_modules\phonegap\node_modules\cordova\node_modules\cordova-lib\node_modules\cordova-common\src\superspawn.js:139:23) at emitTwo (events.js:87:13) at ChildProcess.emit (events.js:172:7) at maybeClose (internal/child_process.js:818:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
What I feel is the problem? I think that phonegap is not being able to download gradle from http://services.gradle.org/distributions/gradle-2.2.1-all.zip as the .gradle folder is empty.
Why I can't resolve it and a possible solution? I have read many answers for similar problems but none of the resolved my error. I am not behind any proxy and have temporarily disabled my firewall and anti-virus. But still I've frequently encountered problems of connecting to servers in eclipse and android sdk.Generally by doing a manual install I was able to overcome them.
I have ran phonegap build android before, I am assuming the problem started when phonegap updated to support gradle. So i was wondering if I can manually the files needed and populate the .gradle folder.