2

Gradle gets stuck when I try to build on the task [:android:generateDebugSources].

I've left it running for hours without a successful build.

I've tried it in Android Studio 1.0.0, 0.8.1, with Gradle versions 2.1.1, 1.12, 1.14, Android plugin versions 0.12.+ and 0.14.4 using the default wrapper as well as local distributions. I've reinstalled Android Studio and rebooted without any luck. Also tried File --> invalidate caches/Restart.

Here is my android package's build.gradle:

buildscript {
repositories
        {
    maven { url 'https://maven.fabric.io/repo' }
}

dependencies {
    classpath 'io.fabric.tools:gradle:1.+'
}
}

apply plugin: 'android'
apply plugin: 'io.fabric'

repositories {

maven { url 'https://maven.fabric.io/repo' }
}

android {
compileSdkVersion 21
buildToolsVersion '21.1.1'

defaultConfig {
    minSdkVersion 11
    targetSdkVersion 21
    versionCode 13
    versionName "onBoarding"
}
buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
    }
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/android-query-full.0.26.8.jar')
compile files('libs/gson-2.3.jar')
compile 'com.android.support:appcompat-v7:21.+'
compile 'com.android.support:support-v4:21.+'
compile 'com.android.support:recyclerview-v7:21.+'
compile 'com.google.android.gms:play-services:6.1.71'
}

And then my project-level gradle.build file:

buildscript {
repositories {
    mavenCentral()
}
dependencies {
    classpath 'com.android.tools.build:gradle:0.12.+'
}
}

allprojects {
repositories {
    mavenCentral()
}
}

Any advice greatly appreciated.

Agree Ahmed
  • 61
  • 1
  • 7
  • Tryin deleting dependencies (imported libs) and start adding them one-by-one, each time using `Clean Project` and see where the error / freeze occurs. – David Kasabji Dec 01 '14 at 21:29
  • Still getting stuck, even without dependencies. – Agree Ahmed Dec 01 '14 at 21:40
  • Have you tried maybe updating the Android Studio to newer version ? it might come with new gradle updates to assist you. I am just checking my gradle.build file, and they are really different. I am using Maven, however, I am not initializing it in my buildscript! Have you tried using Maven with: `File -> Project Structure -> App -> Dependencies -> Add` ? And with leaving your buildscript default (your's not default, according to mine and I didn't manually change it). – David Kasabji Dec 01 '14 at 21:44
  • Added my dependencies through `Project Structure` and took out everything from the buildscript and still stuck... – Agree Ahmed Dec 01 '14 at 21:59
  • Use this answer solved my problem on ubuntu x64 : http://stackoverflow.com/a/31095817/1638277 – avianey Feb 01 '16 at 12:28

4 Answers4

3

Got it! Changing the buildToolsVersion from 21.1.1 to 20 yielded a successful build.

Agree Ahmed
  • 61
  • 1
  • 7
0

You can also, just install the correct version of the tools.

Eric Fossum
  • 2,395
  • 4
  • 26
  • 50
0

I know this is an old question, but I spent a lot of time in this problem and read at least 30 answers until I found out what was hapenning. I constantly got a message that another aplication was locking a file that Android-Studio needed to complete gradle building. Finally, I found out that it was Avast. So I simply deactivated it and the build finished successfully, but it still took a long time (about 10 minutes).

0

Tried below option and it worked!

  1. Add below properties to your .gradle file
org.gradle.daemon=true
org.gradle.parallel=true
  1. Set SLAVE_AAPT_TIMEOUT environment variable to 30 in windows and restart your system. Second solution credit goes to semuzaboi.
Corentin Pane
  • 4,794
  • 1
  • 12
  • 29
c_c
  • 81
  • 2
  • 7