Android Studio stuck on "Gradle: resolve dependencies '_debugCompile'" or 'detachedConfiguration1'
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')
}
}
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:
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.
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:
How come the gradle scripts work just fine in Terminal? (though it seemed slower than usual).
How come THERE IS NO TIMEOUT for that? It surely created a few white hairs today.. ;)
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.
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>