Gradlew throws java.net.SocketException
Asked Answered
B

1

6

So I created a Qt project for Android, but whenever I try to build it I get that exception. I even tried to run the gradlew file in the command line with the same results. Wherever I look online it seems to be a proxy or network issue as pointed out in https://docs.gradle.org/current/userguide/userguide_single.html#properties section 12.3. I double checked with two different networks, and I'm not using a proxy server.

Here is the auto generated build.gradle (is there something wrong with it?)

buildscript {
    repositories {
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.3'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

apply plugin: 'com.android.application'

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
}

android {
    /*******************************************************
     * The following variables:
     * - androidBuildToolsVersion,
     * - androidCompileSdkVersion
     * - qt5AndroidDir - holds the path to qt android files
     *                   needed to build any Qt application
     *                   on Android.
     *
     * are defined in gradle.properties file. This file is
     * updated by QtCreator and androiddeployqt tools.
     * Changing them manually might break the compilation!
     *******************************************************/

    compileSdkVersion androidCompileSdkVersion.toInteger()

    buildToolsVersion androidBuildToolsVersion

    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
            aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
            res.srcDirs = [qt5AndroidDir + '/res', 'res']
            resources.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            assets.srcDirs = ['assets']
            jniLibs.srcDirs = ['libs']
       }
    }

    lintOptions {
        abortOnError false
    }
}

Any pointers or ideas will be appreciated thanks!

[Edit]

Stack trace:

C:\Users\fcente1a\Documents\build-and_test-Android_for_armeabi_v7a_GCC_4_9_Qt_5_
9_0_for_Android_armv72-Debug\android-build>gradlew --verbose
Downloading https://services.gradle.org/distributions/gradle-3.4-bin.zip

Exception in thread "main" java.net.SocketException: Connection reset
        at java.net.SocketInputStream.read(SocketInputStream.java:210)
        at java.net.SocketInputStream.read(SocketInputStream.java:141)
        at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
        at sun.security.ssl.InputRecord.read(InputRecord.java:503)
        at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973)
        at sun.security.ssl.SSLSocketImpl.waitForClose(SSLSocketImpl.java:1769)
        at sun.security.ssl.HandshakeOutStream.flush(HandshakeOutStream.java:124
)
        at sun.security.ssl.Handshaker.kickstart(Handshaker.java:1067)
        at sun.security.ssl.SSLSocketImpl.kickstartHandshake(SSLSocketImpl.java:
1487)
        at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.
java:1351)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1403
)
        at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1387
)
        at sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:
559)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect
(AbstractDelegateHttpsURLConnection.java:185)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLCo
nnection.java:1546)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
nection.java:1474)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(Http
sURLConnectionImpl.java:254)
        at org.gradle.wrapper.Download.downloadInternal(Download.java:60)
        at org.gradle.wrapper.Download.download(Download.java:45)
        at org.gradle.wrapper.Install$1.call(Install.java:62)
        at org.gradle.wrapper.Install$1.call(Install.java:48)
        at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAcc
essManager.java:69)
        at org.gradle.wrapper.Install.createDist(Install.java:48)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)

C:\Users\fcente1a\Documents\build-and_test-Android_for_armeabi_v7a_GCC_4_9_Qt_5_
9_0_for_Android_armv72-Debug\android-build>

[Second Edit]

After changing the url to http (not secure) or having gradlew take a local file I got this:

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'android-build'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve com.android.tools.build:gradle:2.2.3.
     Required by:
         project :
      > Could not resolve com.android.tools.build:gradle:2.2.3.
         > Could not get resource 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom'.
            > Could not GET 'https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.3/gradle-2.2.3.pom'.
               > Connection reset
Boehmite answered 2/6, 2017 at 19:38 Comment(9)
Going to need the whole stack trace / detailed error message if you expect a solution. With just this posting, we have no idea where the exception is coming from.Chemosynthesis
Looks like jcenter might be having problems? Try adding mavenCentral() in your repositories configuration.Chemosynthesis
hmm thanks, but still same error.Boehmite
How about ( just to test ) remove jcenter all together? Both definitions of it.Chemosynthesis
It still looks the same.Boehmite
String, do what the output suggests, then edit your post body. -- For more information, run this command with --verbose.Chemosynthesis
it still seems to be the same... Maybe it's failing connection before it can output anything?Boehmite
I know it will be the same; with verbose, there should be some additional information printed this time. If you could, please edit your original question to include this verbose output. It may have some helpful details.Chemosynthesis
so the stack trace I originally put was from Qt which runs gradlew, and encounters this problem. I ran it just with "gradlew --verbose" and that is the output.Boehmite
C
5

It looks like you encounter an error right after

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

So I just tried hitting this via cURL,

$curl --head https://services.gradle.org/distributions/gradle-3.4-bin.zip

HTTP/1.1 301 Moved Permanently
Date: Fri, 02 Jun 2017 20:13:00 GMT
Connection: keep-alive
Cache-Control: max-age=3600
Expires: Fri, 02 Jun 2017 21:13:00 GMT
Location: https://downloads.gradle.org/distributions/gradle-3.4-bin.zip
Server: cloudflare-nginx
CF-RAY: 368d121d6ad9568d-IAD

This is showing a 301 redirect, which could explain the Connection reset if the download code is not handling it properly. I do not know where this URL comes from, but you could try replacing it with the new destination:

https://downloads.gradle.org/distributions/gradle-3.4-bin.zip

Answer #2

Can you upgrade and use 2.3.0? That appears to be the latest and is definitely available in Central.

Chemosynthesis answered 2/6, 2017 at 20:15 Comment(8)
so that still yields the same error. I did try using http instead, and I got a different error message.Boehmite
That is really odd... How about trying the suggestion posted here, and pointing to the file that you manually download, instead of relying on the internal downloader?Chemosynthesis
That gives me the same as when I use http. It takes a very long time and then it throws a different error message (the new error message is now appended to the question).Boehmite
yep: Downloading file:/C:/Users/fcente1a/Documents/Chrome/gradle-3.4-bin.zip......Boehmite
I'm confused. How is different from mvnrepository.com/artifact/org.gradle/gradle-core/3.5 and where would I put these files. This .jar file doesn't seem to have any of the files at gradke_user_home nor in my gradle file in the project.Boehmite
It is not failing on core, it it failing on the first dependency, > Could not resolve com.android.tools.build:gradle:2.2.3. Please try changing this to use 2.3.0.Chemosynthesis
haha finally a succcesful build! so changing it to 2.3.0 didn't do it, but I changed the repositories in build.gradle from jcentral() to "maven { url "jcenter.bintray.com" }"Boehmite
When I cURLed the endpoint using the command you provided, I too received a 301: Moved Permanently status code. However, the URL that was returned in the Location header did not work: https://github.com/gradle/gradle-distributions/releases/download/v8.5.0/gradle-8.5-bin.zip What did work was to follow the pattern of the Location header that you received in your response and simply change the URL from https://services.gradle.org/distributions/gradle-8.5-bin.zip to https://downloads.gradle.org/distributions/gradle-8.5-bin.zipHambletonian

© 2022 - 2024 — McMap. All rights reserved.