-3

connection timeout error in gradle sync, in android studio 3.3 for sample hello world app in. Earlier it was working with no proxy set in http setting in android studio settings. I have tried other solution from stack overflow. looks like gradle can't download from all urls. now reinstalling studio after completely uninstalling it. Update after reinstalling the problem persists. enter image description here

SOMETIME build clean from GUI does not do anything at all.

Project level Build.gradle file ** Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
    google()
    jcenter()
    mavenCentral()

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

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

allprojects {
repositories {
    google()
    jcenter()
    mavenCentral()

}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

**

App level build.graldle file

apply plugin: 'com.android.application'

android {
compileSdkVersion 28
defaultConfig {
    applicationId "com.example.myapplication"
    minSdkVersion 15
    targetSdkVersion 28
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

Update

After formatting my windows 10 and freshly installed development tools, it now throws Gradle Sync Failed: Read timeout error

Vikas Pandey
  • 1,115
  • 1
  • 15
  • 25
  • 2
    if you are reinstalling android studio then what exactly is the question ?. Can you post your build.gradle file here ? – Umair Feb 05 '19 at 09:45
  • This is a network problem, check your internet connection. Maybe some firewall is blocking you. – Henry Feb 05 '19 at 09:58
  • @Umair, please see my update. – Vikas Pandey Feb 05 '19 at 10:07
  • @VikasPandey as henry said it's a internet connection issue. please check your connection or firewall. Moreover if you want to work offline then follow this link: https://stackoverflow.com/questions/42516117/android-studio-gradle-sync-failed-connection-timed-out-connect – Umair Feb 05 '19 at 10:10
  • @umair, posted my build.gradle file – Vikas Pandey Feb 06 '19 at 07:18
  • @Henry, yes, it looks more like a network issue, i have tested with my mobile hotspot network and my network administrator had disabled firewall too, still not working. – Vikas Pandey Feb 06 '19 at 07:19

2 Answers2

0

Its Network issue fails to build pass offline argument in Gradle

Try ./gradlew tasks --offline

For run Android project in offline mode visit GRADLE CLI docs : Gradle

Android Studio

In Android, studio can make Gradle to build your project in offline mode options :

Settings -- Build, Execution, Deployment -- Build tools -- Gradle

Gradle Offline Android

-1

Solution: that worked for me

setting - language and framework - kotlin - update kotlin plugin version - restart computer - run android studio and now it works and it ran faster Update kotlin plugin version

tried

  1. using local gradle repository

  2. changing no proxy in setting-http

  3. uninstalling, reinstalling, formatting my laptop after 2 days:

i tried to see a kotlin in setting. then there was an update for kotlin,

Vikas Pandey
  • 1,115
  • 1
  • 15
  • 25