Agree Ahmed
Agree Ahmed

Reputation: 61

Gradle Build stuck at generate debug sources

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.

Upvotes: 2

Views: 8716

Answers (4)

c_c
c_c

Reputation: 81

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.

Upvotes: 0

jvdecamargo
jvdecamargo

Reputation: 73

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).

Upvotes: 0

Eric Fossum
Eric Fossum

Reputation: 2472

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

Upvotes: 0

Agree Ahmed
Agree Ahmed

Reputation: 61

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

Upvotes: 3

Related Questions