5

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
Felipe Centeno
  • 2,911
  • 1
  • 21
  • 39

1 Answers1

4

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.

Matt Clark
  • 27,671
  • 19
  • 68
  • 123
  • so that still yields the same error. I did try using http instead, and I got a different error message. – Felipe Centeno Jun 02 '17 at 20:48
  • That is really odd... How about trying the suggestion posted [here](https://stackoverflow.com/a/30017892/1790644), and pointing to the file that you manually download, instead of relying on the internal downloader? – Matt Clark Jun 02 '17 at 20:51
  • 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). – Felipe Centeno Jun 02 '17 at 21:22
  • yep: Downloading file:/C:/Users/fcente1a/Documents/Chrome/gradle-3.4-bin.zip...... – Felipe Centeno Jun 02 '17 at 21:31
  • I'm confused. How is different from https://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. – Felipe Centeno Jun 05 '17 at 15:05
  • 1
    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`. – Matt Clark Jun 05 '17 at 15:13
  • 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 "http://jcenter.bintray.com" }" – Felipe Centeno Jun 05 '17 at 15:51