TheWaterProgrammer
TheWaterProgrammer

Reputation: 8239

Gradle build error while building Qt app for android using androiddeployqt

I have a Qt app for android which I command line building it using a shell script. I want to use gradle. So I am using the following command for the install step.

androiddeployqt --sign mykey.keystore --storepass mypassword --output android-build --verbose --gradle --input MyApp/myapplib.so-deployment-settings.json

I had trouble using gradle 2.2.1. Hence, I updated my gradle wrapper by downloading gradle 3.1. But while running the command gradle still seems to be trying to download 2.2.1 and gives the following error.

Pregenerating entry list for assets file engine.
Downloading https://services.gradle.org/distributions/gradle-2.2.1-all.zip

Exception in thread "main" java.net.UnknownHostException: services.gradle.org
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:184)
    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.<init>(HttpsClient.java:264)
    at sun.net.www.protocol.https.HttpsClient.New(HttpsClient.java:367)
    at     sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.getNewHttpClient(Abs    tractDelegateHttpsURLConnection.java:200)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1124)
    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:61)
    at org.gradle.wrapper.Install$1.call(Install.java:48)
    at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.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)
Building the android package failed!

Can someone please point out how can I get rid of this error & build my Qt app using gradle ?

Upvotes: 4

Views: 4242

Answers (5)

Bouloche
Bouloche

Reputation: 46

Old question, but I have been troubled too by this lately:

I updated my gradle wrapper by downloading gradle 3.1. But while running the command gradle still seems to be trying to download 2.2.1

It turns out that in older Qt versions (at least 5.5.1) androiddeployqt itself modifies the gradle version in your gradle.properties:

bool updateGradleDistributionUrl(const QString &path) 
{
    // check if we are using gradle 2.x
    GradleProperties gradleProperties = readGradleProperties(path);
    QString distributionUrl = QString::fromLocal8Bit(gradleProperties["distributionUrl"]);
    QRegExp re(QLatin1String(".*services.gradle.org/distributions/gradle-2..*.zip"));
    if (!re.exactMatch(distributionUrl)) {
        gradleProperties["distributionUrl"] = "https\\://services.gradle.org/distributions/gradle-2.2.1-all.zip";
        return mergeGradleProperties(path, gradleProperties);
    }
    return true;
}

Upvotes: 1

SwKEmb
SwKEmb

Reputation: 407

as per the https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_environment_variables

define environment variable GRADLE_OPTS with proxy for both http and https like this

GRADLE_OPTS=-Dhttp.proxyHost=123.23.23.123 -Dhttp.proxyPort=8080 -Dhttps.proxyHost=123.23.23.123 -Dhttps.proxyPort=8080

Upvotes: 1

Jay Marm
Jay Marm

Reputation: 576

1st: correct some invalid variables in QT's build settings/build environment (i.e. wrong slash was / instead of )... AND add some. Specifically:

ANDROID_HOME = D:\Android-SDK
ANDROID_SDK_ROOT = D:\Android-SDK
GRADLE_USER_HOME = C:\Users\pc\.gradle
JAVA_HOME = D:\Program Files\Java\jdk1.8.0_201

(obviously these need to be upd for your install directories .i.e usually on C: drive)

Note: I specified these in Windows env settings, but it seems like they need to be specifically set in QT's env overrides.

2nd: remove the 29.0.0RC1 from Android SDK build-tools via Android Studio SDK manager. Apply. Select 'show package details' to then be able to select the 28.0.3 version. Apply.

3rd: go into theQT project/app's folder and edit the gradle.properties file... change the line to:

androidBuildToolsVersion=28.0.3

Finally: you should probably should close and reopen QT and the project.

Upvotes: 1

cxↄ
cxↄ

Reputation: 1348

Windows

Set new variable "_JAVA_OPTIONS" in environment variables with following value

-Dhttp.proxyHost=192.168.0.1 -Dhttp.proxyPort=8080 -Dhttp.proxyUser=1234 -Dhttp.proxyPassword=5678 -Dhttps.proxyHost=192.168.0.1 -Dhttps.proxyPort=8080 -Dhttps.proxyUser=1234 -Dhttps.proxyPassword=5678

Unix

export _JAVA_OPTIONS="-Dhttp.proxyHost=192.168.0.1 -Dhttp.proxyPort=8080 -Dhttp.proxyUser=1234 -Dhttp.proxyPassword=5678 -Dhttps.proxyHost=192.168.0.1 -Dhttps.proxyPort=8080 -Dhttps.proxyUser=1234 -Dhttps.proxyPassword=5678"

Upvotes: 1

TheWaterProgrammer
TheWaterProgrammer

Reputation: 8239

This is a network issue or a proxy issue. If gradle is not able to get through the proxy setting then create a gradle.settings in ~/.gradle or your own defined GRADLE_USER_HOME in PATH.

systemProp.http.proxyHost=proxy
systemProp.http.proxyPort=port
systemProp.http.proxyUser=user
systemProp.http.proxyPassword=password
systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost

Upvotes: 0

Related Questions