Reputation: 2252
I am developping an Android application on Android Studio with 3 collegues and recently, our project cannot be built anymore. We all have different versions of Android Studio (mine is 0.2.8) and it fails to compile on all of them. We aren't able to find what is causing the problem because it happened at different moments for all of us (strangely, with the same project version, the app was building on my Android Studio and not on the one of my collegues).
Sometimes, Android Studio is able to compile my project when it opens it, but then fails when I try to run the app. But most of the time, Android Studio fails to compile my project when it opens it.
I get no error to help me understand the problem, only the message title of the background task can give me a hint of what is happening : Gradle: Resolve dependencies ':_DebugApk'
. This background task never finishes, it just load until the end of time.
I don't know if it is related to the build.gradle file, but here it is in case you can find something wrong.
home = System.getenv("ANDROID_HOME")
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
maven {
url "http://maven.hq.couchbase.com/nexus/content/repositories/releases/"
}
maven {
url "http://files.couchbase.com/maven2/"
}
}
dependencies {
compile 'com.android.support:support-v4:18.0.+'
compile 'com.android.support:appcompat-v7:18.0.+'
compile 'com.google.android.gms:play-services:3.1.36'
compile fileTree(dir: 'libs', include: '*.jar')
compile 'com.couchbase.cblite:CBLite:1.0.0-beta'
compile 'com.couchbase.cblite:CBLiteEktorp:1.0.0-beta'
compile 'com.couchbase.cblite:CBLiteJavascript:1.0.0-beta'
instrumentTestCompile 'com.jayway.android.robotium:robotium-solo:4.3'
}
android {
compileSdkVersion 18
buildToolsVersion "18.1"
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')
}
}
tasks.withType(Compile) {
options.encoding = 'UTF-8'
}
What is Android Studio doing when resolving dependencies? What can cause it to hang like this?
EDIT:
When executing gradle build --info
, it gives me the following error :
FAILURE: Build failed with an exception.
- What went wrong: Execution failed for task ':compileDebug'.
Cannot find System Java Compiler. Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory.
EDIT 2:
Android Studio stopped being able to compile my project again. Now it stops at Gradle: Resolve dependencies ':_ReleaseApk'
. And when I try to compile with gradle via command line, it works without any error...
EDIT 3:
Again, Android Studio is failing at compiling my project. Now it stops at Gradle: Resolve dependencies ':_DebugCompile'
. And when I try to compile with gradle via command line, it works without any error... God I hate Gradle!
Upvotes: 9
Views: 21507
Reputation: 115
In my case one of developers did not include gradle.properties in .gitignore file, and it was the cause of stuck
Upvotes: 0
Reputation: 10583
I think that the problem you are hitting in Edit 3 is connected with those lines:
maven {
url "http://maven.hq.couchbase.com/nexus/content/repositories/releases/"
}
maven {
url "http://files.couchbase.com/maven2/"
}
Some of those repositories is not active any more, and Android Studio has no timeout when checking that (freakin crazy, right?!).
This was my issue at least: Android Studio stuck on "Gradle: resolve dependancies '_debugCompile'" or 'detachedConfiguration1'
Upvotes: 2
Reputation: 2252
After adding the JAVA_HOME variable, I was able to compile my application like usual.
EDIT:
After I got the another error (see EDIT 2 on the question), I just deleted the build folder of my project and it worked again.
EDIT 2:
It stopped working again (see EDIT 3 on the question)
Upvotes: 2