Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Gradle #414

Closed
enchev opened this issue Apr 11, 2016 · 15 comments
Closed

Problem with Gradle #414

enchev opened this issue Apr 11, 2016 · 15 comments

Comments

@enchev
Copy link

enchev commented Apr 11, 2016

From @munseym on April 5, 2016 23:16

tns doctor recognizes my gradle installation:
log2.txt

However, when I run tns run android or tns emulate android, it tries to download gradle, and fails on the proxy setting. Proxy is correctly set in config.json, but this piece does not seem to honor that setting. Proxy is also set in the Java installation and http_proxy environment variable.

C:\Users\xxxx\Documents\angular\sample-ng-todomvc>tns run android
Executing before-prepare hook from C:\Users\xxxx\Documents\angular\sample-ng-todomvc\hooks\before-prepare\nativescript-dev-typescript.js
Found peer TypeScript 1.8.9
Project successfully prepared
Downloading https://services.gradle.org/distributions/gradle-2.8-bin.zip

Exception in thread "main" 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 sun.security.ssl.SSLSocketImpl.connect(SSLSocketImpl.java:668)
at sun.security.ssl.BaseSSLSocketImpl.connect(BaseSSLSocketImpl.java:173)
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.protocol.https.HttpsClient.(HttpsClient.java:264)
at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(AbstractDelegateHttpsURLConnection.java:191)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1105)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:999)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:177)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1513)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at org.gradle.wrapper.Download.downloadInternal(Download.java:58)
at org.gradle.wrapper.Download.download(Download.java:44)
at org.gradle.wrapper.Install$1.call(Install.java:59)
at org.gradle.wrapper.Install$1.call(Install.java:46)
at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
at org.gradle.wrapper.Install.createDist(Install.java:46)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:126)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Command C:\Users\xxxx\Documents\angular\sample-ng-todomvc\platforms\android\gradlew.bat failed with exit code 1

Copied from original issue: NativeScript/NativeScript#1897

@enchev
Copy link
Author

enchev commented Apr 11, 2016

From @xuezier on April 6, 2016 7:43

set the http proxy to the download.
In Console window. enter the code:
set http_proxy=http://127.0.0.1:your_proxy_port
set https_proxy=http://127.0.0.1:your_proxy_prot
then:
tns run android
Should be able to solve the problem.

@enchev
Copy link
Author

enchev commented Apr 11, 2016

From @NickIliev on April 6, 2016 11:17

@munseym
Can you verify @xuezier solution?

Also you can check the following steps as described here

  • On your file system, locate the directory where the nativescript npm package is installed.
  • In a text editor, open config → config.json.
  • Set USE_PROXY to true.
  • Set PROXY_PORT.
  • Set PROXY_HOSTNAME.
  • Make sure to preserve the quotation marks and commas as in the initial config.json file.

Alternativly you can check this discussion #302

@Plamen5kov
Copy link
Contributor

Plamen5kov commented Apr 14, 2016

Hi @munseym,
Did you try what @NickIliev suggested? If you're trying to use a proxy, this might help.

@pablodenadai
Copy link

Same issue here - none of the proposed solutions above seem to work.

@pablodenadai
Copy link

Fixed it by adding the following line inside the gradlew.bat file:

set DEFAULT_JVM_OPTS="-Dhttps.proxyHost=HOST -Dhttps.proxyPort=PORT -Dhttps.proxyUser=USER -Dhttps.proxyPassword=PASSWORD -Dhttp.proxyHost=HOST -Dhttp.proxyPort=PORT -Dhttp.proxyUser=USER -Dhttp.proxyPassword=PASSPWORD"

Please note that the HOST property doesn't take the http:// prefix.

@Plamen5kov
Copy link
Contributor

Hi @ghpabs,
Thank you for sharing this workaround.
Because gradlew.bat, shouldn't be changed because it's created by the wrapp command and it can be easily overridden, it's better to set the properties you described in the gradle.properties. You can read about more about gradle.properties file here

@Kurara
Copy link

Kurara commented Aug 8, 2016

Hello @enchev
I tried to "locate the directory where the nativescript npm package is installed" and I don't find where in filesystem is. Where should it be?

@Plamen5kov
Copy link
Contributor

@Kurara if you have the same gradle problem with proxies use @ghpabs workaround.

@Kurara
Copy link

Kurara commented Aug 8, 2016

Thank you. I tried also adding that line to gradlew.bat and It doesn't fix it. I hate these proxys and all the problems they make always. Sorry for necromancing post u.u The problem says:

Downloading https://services.gradle.org/distributions/gradle-2.8-bin.zip

Exception in thread "main" java.net.ConnectException: Connection timed out: connect

@Plamen5kov
Copy link
Contributor

@Kurara you shouldn't change the gradle.bat file as it easily is overridden. You need to make the proxy configuration in the gradle.properties file located in <app_name>/platforms/android/gradle.properties: see more here

@Kurara
Copy link

Kurara commented Aug 8, 2016

@Plamen5kov thank you very much but it seems I'm not able to make it run. Should I open a new post with my problem or paste it here? I dont have gradle.properties but I found android\gradle\wrapper\gradle-wrapper.properties

@Plamen5kov
Copy link
Contributor

Plamen5kov commented Aug 8, 2016

@Kurara if your problem is the same as described here, you must create gradle.properties as described in the link I send you. If your problem is with the gradle proxies feel free to reopen this issue.

Edit:

  • go to <app_name>/platforms/android/
  • create gradle.properties file
  • paste this content and fill in the HOST, PORT, USER and PASSWORD fields

@Kurara
Copy link

Kurara commented Aug 8, 2016

I fixed it! I forgot to wirte https proxy. I create gradle.properties and modified both it and gradle-wrapper.properties

@Fabiyo-90
Copy link

there's no way to download hte gradle of zip and install it manuelly ?

@petekanev
Copy link
Contributor

@Fabiyo-90 the proposed solutions in http://stackoverflow.com/questions/22896569/how-to-use-gradle-zip-in-local-system-without-downloading-when-using-gradle-wrap are all valid. Feel free to experiment. Mind you, when uninstalling/deleting the platforms directory you will delete the gradle wrapper properties file, so you need to work out a way to make the changes persistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants