Android Studio stuck on "Gradle: resolve dependencies '_debugCompile'" or 'detachedConfiguration1'

AndroidAndroid Studio

Android Problem Overview


I have no idea what I changed in my project, but it suddenly cannot get past this step while building gradle scripts.

There is no problem building it with just 'gradle assemble'.

EDIT: the previous stuck point was resolve dependencies 'detachedConfiguration1'. (After the first failed attempt of _debugCompile, I'm back at detachedConfiguration1). I guess it is too many dependency projects? Some sample projects I have are imported just fine in the Studio.... I reinstalled the Android Studio and removed all the settings and preferences as well.

I have to kill it every time it starts doing this.

Ring any bells?

import com.android.build.gradle.AppPlugin
import com.android.build.gradle.LibraryPlugin

// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript {
repositories {
    mavenCentral()
}

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

apply plugin: 'android'

repositories {
    maven { url 'http://ksoap2-android.googlecode.com/svn/m2-repo' }

    mavenCentral()
}

dependencies {

    compile 'com.google.code.ksoap2-android:ksoap2-android:2.5.2'
    compile 'com.android.support:support-v4:18.0.+'
    compile fileTree(dir: 'libs', include: '*.jar')
    compile project(':lib-projects:StickyListHeaders')
    compile project(':lib-projects:ActionBar-PullToRefresh')
    compile project(':lib-projects:facebook')
    compile project(':lib-projects:Mopub:mopub-sdk')
    compile project(':lib-projects:NineOldAndroids')
    compile project(':lib-projects:ActionBarSherlock:actionbarsherlock')
    compile project(':lib-projects:ActionBarSherlock:actionbarsherlock-i18n')
    compile project(':lib-projects:SmoothProgressBar')
    compile project(':lib-projects:android-viewflow-master:viewflow')
}

android {

    signingConfigs {

        debug {
            storeFile file('....')
        }
    }

    compileSdkVersion 19
    buildToolsVersion "19.0.3"
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            resources.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
        }

        // Move the tests to tests/java, tests/res, etc...
        //instrumentTest.setRoot('tests')

        // Move the build types to build-types/<type>
        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...

        // This moves them out of them default location under src/<type>/... which would
        // conflict with src/ being used by the main source set.
        // Adding new build types or product flavors should be accompanied
        // by a similar customization.
        debug.setRoot('build-types/debug')
        release.setRoot('build-types/release')

    }
}

Android Solutions


Solution 1 - Android

I've encountered this problem far too frequently since i switched over to Android Studio. This is indeed an issue with the repository not being accessible - either due to a network issue or, more likely, the repo being down for whatever reason.

The simplest work-around that I've found is to just select the "work offline" mode within the Android Studio preferences. This doesn't help if you need to add a new dependency, but if you already have all your dependencies added it does the trick.

To enable this setting go to:

> Preferences -> Gradle

In the right side options go down to "Global Gradel Settings" and check the "Offline work" box.

The box should look like:

enter image description here

You can periodically uncheck this box to see if the repo is back online.

NOTE: This option is the equivalent of setting the --offline flag when running a gradle build from the command line.

Solution 2 - Android

It turns out that this line:

repositories {     
  maven {     
    url 'http://ksoap2-android.googlecode.com/svn/m2-repo'    
  }

is solely responsible for forever-stuck Android studio. Probably the repository is not active/offline today...

Interesting questions:

  1. How come the gradle scripts work just fine in Terminal? (though it seemed slower than usual).

  2. How come THERE IS NO TIMEOUT for that? It surely created a few white hairs today.. ;)

Solution 3 - Android

Please run gradle from command line (opening a terminal in your project folder) using -info and check where it stop. I was experiencing something similar and it was related with jcenter(), because it can't reach a resource:

Resource missing. HTTP GET

so, changing jcenter() by mavenCentral() in MyProject/build.gradle did the trick.

I hope it can help.

Solution 4 - Android

I encountered the same issue and resolved it by adding both http and https proxies in the gradle.properties file. It is important to add the https proxy as the gradle-2.10-all.zip is read using https:

https://services.gradle.org/distributions/gradle-2.10-all.zip

gradle.properties:

systemProp.http.proxyHost=<http proxy name>
systemProp.http.proxyPort=<http proxy port>
systemProp.https.proxyHost=<https proxy name>
systemProp.https.proxyPort=<https proxy port>

Solution 5 - Android

On the Debian,

I have the same problem, fixed for me with two changes,

First enable proxy for gradle on the gradle.properties file, both for http and https:

systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=8080

And then next by installing lib32stdc++6 and lib32z1 packages:

$ sudo apt-get install lib32stdc++6 lib32z1

I discover my problem with enabling debug and info option for gradlw command, that I run it on the root of project:

First with this command:

./gradlew --info --debug 

And next with this command:

./gradlew --info --debug :app:generateDebugSources

Output debug (On Android Gui this section run again and agian on the background without you know about error message ):

23:25:45.419 [ERROR] [system.err] Exception in thread "png-cruncher_10" java.lang.RuntimeException: Timed out while waiting for slave aapt process, make sure the aapt execute at /local/path/to/Android/sdk/build-tools/22.0.1/aapt can run successfully (some anti-virus may block it) or try setting environment variable SLAVE_AAPT_TIMEOUT to a value bigger than 5 seconds
23:25:45.419 [ERROR] [system.err] 	at com.android.builder.png.AaptProcess.waitForReady(AaptProcess.java:108)
23:25:45.419 [ERROR] [system.err] 	at com.android.builder.png.QueuedCruncher$1.creation(QueuedCruncher.java:110)
23:25:45.419 [ERROR] [system.err] 	at com.android.builder.tasks.WorkQueue.run(WorkQueue.java:203)
23:25:45.419 [ERROR] [system.err] 	at java.lang.Thread.run(Thread.java:745)

Solution 6 - Android

Check http://bintray.com (jcenter) or http://maven.org (mavenCentral) from your browser and change repositories setting in the build.gradle according to available site.

Solution 7 - Android

If you are using a proxy server then you might have to set the JVM parameters for your proxy.

Settings -> Gradle -> Gradle VM options: -Dhttp.proxyHost=1.2.3.4 -Dhttp.proxyPort=8080 Settings -> Compiler -> VM options: -Dhttp.proxyHost=1.2.3.4 -Dhttp.proxyPort=8080

I had to restart the IDE for these settings to take effect.

Solution 8 - Android

Just providing my experience in case others run into the following scenario.

The problem for me was one of my repositories was hosted on my companies network and not the public network. After VPN'ing I was able to "resolve the dependency."

Solution 9 - Android

I fixed mine by copying the Gradle settings in a working project and pasting them into the bad build.gradle file.

Solution 10 - Android

I've got similar problem today, and in my case I found it is because one of my external dependencies have difficulty being pulling from the internet.

Here's how I solved it:

Step 1

Check the dependencies in build.gradle files in the app (or the library modules, according to where your problem occured).

For example, it might look like this:

dependencies {
    ...
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.amazonaws:aws-android-sdk-iot:2.2.20'
}

Step 2

Guess which ones might be the root cause (ie. the one which looks harder to pull).

In my case, I think 'com.amazonaws:aws-android-sdk-iot:2.2.20' looks suspicious, so I comment it out and then try to build Gradle again. This time, the Gradle build is successful.

Step 3

Search for other artifact versions.

In my case, I searched https://bintray.com/bintray/jcenter/com.amazonaws%3Aaws-android-sdk-iot and found 2.2.21, 2.2.22 are also available (currently).

I tried 2.2.21 in my build.gradle, and the Gradle build works now!!

dependencies {
    ...
    compile 'com.amazonaws:aws-android-sdk-iot:2.2.21'
}

Other References

To know more about external dependencies in Gradle, check these sites:

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDanailView Question on Stackoverflow
Solution 1 - AndroidSBerg413View Answer on Stackoverflow
Solution 2 - AndroidDanailView Answer on Stackoverflow
Solution 3 - Androidlm2aView Answer on Stackoverflow
Solution 4 - AndroidcahmazndnrView Answer on Stackoverflow
Solution 5 - AndroidOmid RahaView Answer on Stackoverflow
Solution 6 - AndroidAmir SaniyanView Answer on Stackoverflow
Solution 7 - AndroidasifgoldpkView Answer on Stackoverflow
Solution 8 - AndroidRyhanView Answer on Stackoverflow
Solution 9 - AndroidR MView Answer on Stackoverflow
Solution 10 - AndroidKai-Hui LiangView Answer on Stackoverflow