First of all I want to admit that I know most of questions about gradle problems. It's not a duplicate. Problem is similar to others but all solutions failed. Problem has happened when I've added google play services ads lib. Before it app had been building properly. After addition classical problem occurs.
Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-7-oracle/bin/java'' finished with non-zero exit value 1
in some cases exit value was 3
I have changed gradle file many times with several module exclusions, enlarging android studio heap size and many other possibilities. After all tries I cannot figure out what is wrong.
Gradle file:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'com.google.gms.google-services'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven { url "https://clojars.org/repo/" }
maven { url "https://jitpack.io" }
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "xxx"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dexOptions {
preDexLibraries = false
//I have also tried enlarging heap size here
}
buildTypes {
release {
shrinkResources true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
lintOptions {
checkReleaseBuilds false
}
}
dependencies {
compile 'com.android.support:multidex:1.0.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
apt "com.google.dagger:dagger-compiler:2.0.2"
// Needed for @Generated annotation (missing in Java <= 1.6; therefore, Android)
compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') {
transitive = true;
}
//ads lib ruined building
compile 'com.google.android.gms:play-services-ads:8.3.0'
compile("com.google.android.gms:play-services-gcm:8.3.0") {
exclude module: 'httpclient' //by artifact name
exclude group: 'org.apache.httpcomponents' //by group
exclude group: 'org.apache.httpcomponents', module: 'httpclient' //by both name and group
}
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile 'com.google.guava:guava:19.0'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.squareup.okhttp:okhttp:2.7.4'
compile('com.squareup.retrofit2:retrofit:2.0.0-beta4') {
exclude module: 'okhttp'
}
compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0-beta4'
compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'
compile 'com.google.code.gson:gson:2.5'
compile 'com.google.dagger:dagger:2.0.2'
compile('com.google.apis:google-api-services-youtube:v3-rev162-1.21.0') {
exclude group: 'com.google.guava'
exclude module: 'httpclient' //by artifact name
exclude group: 'org.apache.httpcomponents' //by group
exclude group: 'org.apache.httpcomponents', module: 'httpclient' //by both name and group
}
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
compile 'io.reactivex:rxandroid:1.1.0'
compile 'io.reactivex:rxjava:1.1.0'
compile 'com.github.orhanobut:logger:1.12'
compile 'javax.annotation:jsr250-api:1.0'
compile 'frankiesardo:icepick:3.1.0'
apt 'frankiesardo:icepick-processor:3.1.0'
}
I don't want to use whole google play services lib.
Gradle console output when the error occurs:
:app:transformClassesWithDexForDebug
Uncaught translation error: java.util.concurrent.ExecutionException:
java.lang.OutOfMemoryError: GC overhead limit exceeded Uncaught translation error:
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError:
GC overhead limit exceeded 2 errors; aborting FAILED