Error : Connection timed out: connect ? While building project gradle - java

I am getting error while building the gradle (IDE tool version 3.1.3 android)
android version : 3.1.3
gradle version : 4.4
Not able to download files below when gradle sync
Download https://jcenter.bintray.com/com/android/tools/build/gradle/3.1.3/gradle-3.1.3.pom 21s 215ms
Download https://dl.google.com/dl/android/maven2/com/android/tools/build/gradle/3.1.3/gradle-3.1.3.pom 1m 24s 138ms
Download http://maven.google.com/com/android/tools/build/gradle/3.1.3/gradle-3.1.3.pom 21s 84ms
Error : Connection timed out: connect
Please help me to solve this problem

Are you working behind a proxy?
try to run
./gradlew assemble --debug --info --stacktrace
And share your log information please.
Besides that, check your gradle.properties to see if you have any proxy configured? If you are not behind any proxy, please remove those settings.
Also, please be sure that "google()" repo is added and put as the first inside your buildscripts block. E.g.
buildscript {
repositories {
//jcenter() //Should remove this repository for Android Gradle Plugin 3.0+, and use google() repository as shown below
google()
maven {
url "https://plugins.gradle.org/m2/"
}
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}

Related

E-Iceblue Spire PDF Free Jenkins Timeout

I'm trying to use the Spire Free PDF library from the E-Iceblue repository and it just takes too long for the dependency to be downloaded on my computer. The big problem is that I use Jenkins for CI/CD and it gives me a timeout error:
What went wrong:
Execution failed for task ':compileJava'.
> Could not download spire.doc.free-3.9.0.jar (e-iceblue:spire.doc.free:3.9.0)
> Could not get resource 'http://repo.e-iceblue.com/nexus/content/groups/public/e-iceblue/spire.doc.free/3.9.0/spire.doc.free-3.9.0.jar'.
> Read timed out
I tried to increase the timeout using these two properties in the Gradle Wrapper, but without success:
/gradlew build -Dorg.gradle.internal.http.socketTimeout=60000 -Dorg.gradle.internal.http.connectionTimeout=60000 jacocoTestReport
On my personal computer, it takes around 5 minutes to download the dependency. On my work computer, where I have the VPN provided by my company, the download time is the same: 4-5 minutes. The Jenkins that I'm using is hosted by my company to manage different projects and the Gradle file looks like this:
repositories {
mavenCentral()
maven {
url "http://repo.e-iceblue.com/nexus/content/groups/public/"
}
}
dependencies {
implementation group: 'e-iceblue', name: 'spire.doc.free', version: '3.9.0'
}
Is there something I can do to fix this issue? Or maybe there is a problem with the repository itself?
You should use "https" instead of "http":
repositories {
mavenCentral()
maven {
url "https://repo.e-iceblue.com/nexus/content/groups/public/"
}
}

Android Studio - Rebuild Project - Could not download aapt2-4.1.0-6503028-windows.jar

This is the configuration I have on my project:
Android Studio 4.1 (September 23, 2020)
Android Gradle Plugin Version 4.1.0
Gradle Version 6.7
Compile SDK 29 (Android 10.0 Q)
Build Tools 29.0.2
Min Sdk 17
Target Sdk 26 (Android 8.0 Oreo)
In the build.gradle of the project I have
buildscript {
repositories {
google()
jcenter()
}
}
....
allprojects {
repositories {
google()
jcenter()
maven { url "https://jitpack.io" }
}
}
When I use the "Build> Rebuild Project" command in Build Output I get this error:
Execution failed for task ':app:mergeDebugResources'.
Could not resolve all files for configuration ':app:_internal_aapt2_binary'.
Could not download aapt2-4.1.0-6503028-windows.jar (com.android.tools.build:aapt2:4.1.0-6503028): No cached version available for offline mode
Possible solution:
- Disable offline mode and rerun the build
I tried with the "Toggle Offline Mode" in the Gradle panel (both to set it and to remove it), but the error still occurs.
I tried to clean the whole .gradle folder but same result.
I also created an emulator with API 30 because they suggested it would download the missing package, but it didn't change the situation.
I tried to manually download the jar (https://maven.google.com/web/index.html?q=aapt2#com.android.tools.build:aapt2:4.1.0-6503028) and put it in libs, but the error still comes out.
A month too late for this, but I was also getting a similar error with not being able to download aapt2, but for a different version number.
Turns out, the order of the google() dependency mattered as mentioned here: https://developer.android.com/studio/releases/#aapt2_gmaven
So everywhere you are adding the dependency for google() move it up, and it should work for you as well.
copy this
implementation 'com.android.tools.build:aapt2:4.1.0-6503028'
in Gradle in the Android Studio after that click Sync Now after finished click run to try

Trying to run SonarScanner with gradle on the open-source Conversations app

To learn about SonarQube I'm using the open-source app called Conversations and I'm trying to run SonarScanner with gradle. I have directly cloned the project from git and added the following configuration in the build.grade:
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.8"
}
}
apply plugin: "org.sonarqube"
And when I run the command "gradle sonarqube" in the root folder I get the following error:
Execution failed for task ':compileConversationsPlaystoreSystemDebugJavaWithJavac'.
I don't understand how to run sonarscanner with gradle and would appreciate if someone could point me to the right direction.

Gradle error after updating to implementation 'com.google.android.gms:play-services-ads:15.0.2' and classpath 'com.google.gms:google-services:3.3.0'

I updated com.google.android.gms:play-services-ads to 15.0.2 and classpath com.google.gms:google-services: to 3.3.0 then i got this error;
Could not GET 'https://s3.amazonaws.com/moat-sdk-builds/com/google/android/gms/play-services-ads/15.0.2/play-services-ads-15.0.2.pom'. Received status code 403 from server: Forbidden
Enable Gradle 'offline mode' and sync project
I enabled gradle offline but i get this error:
No cached version of com.google.android.gms:play-services-ads:15.0.2 available for offline mode.
Disable Gradle 'offline mode' and sync project
Please help.
allprojects {
repositories {
google()
jcenter()
maven { url "https://s3.amazonaws.com/moat-sdk-builds" }
}
}
I don't think version 15.0.2 of google play ads has been released out yet. Use the following:
implementation 'com.google.android.gms:play-services-ads:15.0.1'
You can find latest releases of Google's libraries here.
Also note that Firebase(Google) has started versioning libraries separately. You can find more details by following this link: https://firebase.google.com/support/release-notes/android

Gradle maven plugin: uploadArchives cannot find /tmp/gradle_empty_settings xml

I just switched from Eclipse and Maven to Android Studio and Gradle for my Android projects.
Now I would like my Jenkins server to build and upload release versions to my self hosted Nexus server.
For this I added those lines to my build.gradle
apply plugin: 'maven'
group = "de.myapp"
version = '2.2.0'
android {
...
}
uploadArchives {
repositories {
mavenDeployer {
maven {
name "snapshot_repo"
url "http://192.168.178.85:8081/nexus/content/repositories/myapp_snapshots"
credentials {
username "admin"
password "admin123"
}
}
}
}
}
The building process works fine but I can't upload any project to the Nexus server without getting this strange message:
:myapp_testname:assembleDebug
:myapp_testname:uploadArchives
Upload http://192.168.178.85:8081/nexus/content/repositories/myapp_snapshots/de/myapp/myapp_testname/2.2.0/ivy-2.2.0.xml
Upload http://192.168.178.85:8081/nexus/content/repositories/myapp_snapshots/de/myapp/myapp_testname/2.2.0/ivy-2.2.0.xml.sha1
[ant:null] Error reading settings file '/tmp/gradle_empty_settings56173630026020664.xml' - ignoring. Error was: /tmp/gradle_empty_settings56173630026020664.xml (No such file or directory)
BUILD SUCCESSFUL
Total time: 3 mins 31.555 secs
Build step 'Invoke Gradle script' changed build result to SUCCESS
Archiving artifacts
Finished: SUCCESS
I will get two ivy files on the repository but nothing more.
It seems like gradle cannot create the tmp file. But I don't know why.
When I execute this on my local windows machine I will get the same error (just with another tmp folder)
Does anyone know how to solve this issue?
Well, I just found the problem and the solution:
I'm using several flavors and buildTypes (free/premium and debug/release) in my app.
This means there is no real "default" variant.
In this case you need this line in your module's build.gradle to publish your different build types
android {
...
publishNonDefault true
...
}

Categories