Why Gradle gives this error? [duplicate] - android

This question already has answers here:
Out of memory issue after updating buildToolsVersion '23.0.1' in Android studio
(7 answers)
Closed 6 years ago.
I am building an app where I am using Location Fused Provider and Firebase cloud messaging. When I were using just Firebase cloud messaging everything was okay, but when I added Fused Locations and wanted to build app, console gives me this error:
Error:Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
Error:1 error; aborting
:presentation:transformClassesWithDexForDebug FAILED
Error:Execution failed for task ':presentation:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: `com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-oracle/bin/java'' finished with non-zero exit value 1`
This is my gradle:
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
compileOptions.incremental = false
defaultConfig {
applicationId "com.telnet.asp"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
dataBinding {
enabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
apt 'com.google.dagger:dagger-compiler:2.2'
provided 'javax.annotation:jsr250-api:1.0'
compile project(path: ':domain')
compile project(path: ':data')
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.fasterxml.jackson.core:jackson-databind:2.7.0-rc2'
compile 'com.android.support:design:23.4.0'
compile 'javax.inject:javax.inject:1'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.1.0'
compile 'io.reactivex:rxandroid:1.2.1'
compile 'io.reactivex:rxjava:1.1.6'
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
compile 'com.google.dagger:dagger:2.2'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.jakewharton:butterknife:6.1.0'
compile 'net.danlew:android.joda:2.9.4.1'
compile 'com.android.support:percent:23.4.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.google.firebase:firebase-messaging:9.0.0'
compile 'com.google.android.gms:play-services:9.0.0'
}
apply plugin: 'com.google.gms.google-services'
Does anyone know how to fix this? Please help.

Try add
dexOptions {
javaMaxHeapSize "4g"
}

You need to add dexOptions to your build.gradle:
android {
compileSdkVersion 24
buildToolsVersion "23.0.3"
// ...
dexOptions {
incremental = true;
preDexLibraries = false
javaMaxHeapSize "4g" // 2g should be also OK
}
}

Your application is trying to allocate a larger amount of memory and is going OutOfMemory because it fails to.
Make sure to increase the javaMaxHeapSize with
android {
//...
dexOptions {
incremental = true;
javaMaxHeapSize "4g" // tweak the value here if you need/want
}
// ...
}
Also, check this google link regarding this error by checking their stack trace

Related

:app:dexDebug'. com.android.ide.common.process.ProcessException

I am developing an Android application and getting this error.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_40\bin\java.exe'' finished with non-zero exit value 2
I searched for this on google and come to know that this error comes if I exceeded the dex limit imposed by Android. I tried different suggested solutions
like
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
and
dexOptions {
preDexLibraries = false
javaMaxHeapSize "4g"
}
But this cause other problems in my application. I am not using too much libraries in Gradle file but I don't know why this error coming.
Here is my Gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "ifisol.pinocal"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven { url "https://repo.commonsware.com.s3.amazonaws.com" }
maven {
url "https://s3.amazonaws.com/repo.commonsware.com"
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:design:23.2.0'
compile 'com.github.siyamed:android-shape-imageview:0.9.+#aar'
compile 'at.blogc:expandabletextview:1.0.1#aar'
compile project(':tedpicker')
compile 'cn.pedant.sweetalert:library:1.3'
compile 'com.hedgehog.ratingbar:app:1.1.2'
compile 'com.leavjenn.smoothdaterangepicker:library:0.2.0'
compile files('libs/gson-2.4.jar')
compile files('libs/picasso-2.5.2.jar')
compile 'com.google.android.gms:play-services:8.3.0'
}
I need to have a some solid solution to this problem because this problem has already wasted my one whole day. I will be very thankful for any kind of help.

Execution failed ':app:transformClassesWithDexForDebug' - GC overhead limit exceeded

have a problem with gradle, my app wont compile and appear this error on "0:Messages" tab, here my code on my build.gradle(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "app.nucleo.com.doctoc"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dexOptions {
incremental = true;
preDexLibraries = false
javaMaxHeapSize "4g" // 2g should be also OK
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile project(path: ':backend', configuration: 'android-endpoints')
compile 'com.android.volley:volley:1.0.0'
compile 'com.android.support:appcompat-v7:24.0.0-alpha2'
compile 'com.android.support:support-v4:24.0.0-alpha2'
compile 'com.android.support:design:24.0.0-alpha2'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.android.gms:play-services-gcm:8.4.0'
compile 'com.google.android.gms:play-services-auth:8.4.0'
compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.28'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services-ads:8.4.0'
}
screenshot:
http://i.stack.imgur.com/6BTaw.png
any can help me?
remove from your dependencies:
compile 'com.google.android.gms:play-services:8.4.0'
and look exactly for what else you need from play-services from here.
Fine tune your play-services so you don't include the entire package. Then it won't exceed the 64k function limit and you can remove the multidex thing that I assume you added because it was objecting.
multiDexEnabled false
And the exact play services so it all fits in the same same dex file.

Android - transform Classes With Dex For Debug

My project was working fine until I added the Facebook dependency.
I've started getting this error.
I've read many question, the problem seems to be related to MultiDex.
But none of the solutions worked for me
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-openjdk-amd64/bin/java'' finished with non-zero exit value 1
Even after I remove what I've added, it still show and also gradle seems to be taking a lot of time while building than usual
Here is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "net.ciblo.spectrodraft"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.android.support:multidex:1.0.1'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:cardview-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile 'com.daimajia.easing:library:1.0.1#aar'
compile 'com.daimajia.androidanimations:library:1.1.3#aar'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.pnikosis:materialish-progress:1.5'
compile 'com.nineoldandroids:library:2.4.+'
compile 'com.michaelpardo:activeandroid:3.1.0-SNAPSHOT'
compile 'com.android.support:support-v4:23.2.1'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
}
Adding the following code to build.gradle app module solved my problem
android{
defaultConfig {
// Enabling multidex support.
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
}
dependencies {
//...
compile 'com.android.support:multidex:1.0.0'
}
you can selectively compile Google Play service APIs into your app. For example, to include only the Google Fit and Android Wear APIs, replace the following line in your build.gradle file:
compile 'com.google.android.gms:play-services:8.4.0'
with these lines:
compile 'com.google.android.gms:play-services-fitness:8.4.0'
compile 'com.google.android.gms:play-services-wearable:8.4.0'
==> to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.
Adding the following in build.gradle fixed the issue for me,
android {
//...
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
//...
}
This horrendous recurring issue hit me again recently. The gradle build stalls permanently at app:transformClassesWithDexForDebug, just running for hours and never completing. This time I fixed it by removing all references to 'fabric', a new layer of Crashlytics being pushed on us.
//apply plugin: 'io.fabric' //REMOVE
//classpath 'io.fabric.tools:gradle:1.26.1' //REMOVE

Android Studio this error 3 Java when returning to Run the application

Run the application by pressing returning this error:
Error:Execution failed for task ':myproject:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_51\bin\java.exe'' finished with non-zero exit value 3
My project has the lib facebook sdk and wheellib.
I realized that Android Studio is a long time processing the Gradle and after that displays this error and the application never starts (Run)
My gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId 'br.com.myproject'
minSdkVersion 19
targetSdkVersion 23
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':facebookSDK')
compile project(':wheellib')
compile files('libs/comscore.jar')
compile files('libs/FlurryAnalytics-5.5.0.jar')
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.google.code.gson:gson:2.3'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'joda-time:joda-time:2.4'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services-ads:8.3.0'
compile 'com.google.android.gms:play-services-identity:8.3.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
}
You must run this command at your terminal:
your-project-directory:$> gradle build --info --stacktrace
Then you will see the exactly moment that te gradle task fail.
I believe that the problem is that you are probably facing the 64k method limit.
i had this problem today too, it was in SDK that needs JDK 1_7 only ! I add it in gradle
compileOptions {
//noinspection GroovyAssignabilityCheck
sourceCompatibility JavaVersion.VERSION_1_7
//noinspection GroovyAssignabilityCheck
targetCompatibility JavaVersion.VERSION_1_7
}
then change yours HOME_JAVA on computer to JDK version 1_7 and change Java version in Android Studios Project structure to 1_7 that is all i do.
You may just check compatibility all yours JDK requirements or it may be 64+ methods problem too...
I changed my build.gradle and work! Added dexOptions:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId 'br.com.myproject'
minSdkVersion 19
targetSdkVersion 23
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
compileOptions {
//noinspection GroovyAssignabilityCheck
sourceCompatibility JavaVersion.VERSION_1_7
//noinspection GroovyAssignabilityCheck
targetCompatibility JavaVersion.VERSION_1_7
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}
dependencies {
compile project(':facebookSDK')
compile project(':wheellib')
compile files('libs/comscore.jar')
compile files('libs/FlurryAnalytics-5.5.0.jar')
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.google.code.gson:gson:2.3'
compile 'com.squareup.picasso:picasso:2.3.2'
compile 'joda-time:joda-time:2.4'
compile 'com.google.android.gms:play-services:8.3.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.5.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.android.gms:play-services-ads:8.3.0'
compile 'com.google.android.gms:play-services-identity:8.3.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
}

Picasso causes Execution failed for task ':app:dexDebug'

I'm using Android studio and I'm trying to add Picasso library to my project, but whenever I try to run the app I'm having this error
Error:Execution failed for task ':app:dexDebug'.
com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2
Here is my Gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "22.0.0"
defaultConfig {
applicationId "com.example"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.facebook.android:facebook-android-sdk:3.21.1'
//TODO::Update to the latest version of Play Service
compile 'com.google.android.gms:play-services:6.5.87'
compile 'com.lorentzos.swipecards:library:1.0.8'
compile 'com.android.support:support-v4:22.0.0'
compile 'ch.halarious:halarious-core:0.11'
compile 'com.google.code.gson:gson:2.3.1'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
compile 'com.soundcloud.android:android-crop:0.9.10#aar'
compile 'de.hdodenhof:circleimageview:1.2.2'
compile 'commons-io:commons-io:2.0.1'
compile 'com.integralblue:httpresponsecache:1.0.0'
compile 'com.koushikdutta.ion:ion:2.1.3’
//Here is the Picasso compile line
compile 'com.squareup.picasso:picasso:2.3.3'
}
I' using the latest version of JDK for Mac "jdk-8u45-macosx-x64". BTW, I have tried those solutions (Clean, Build, restart) so no need to suggest them
Thanks in advance
May you are facing the 65k method limit problem.
https://developer.android.com/tools/building/multidex.html
please put this in your default Config:
default Config {
minSdkVersion 14
targetSdkVersion 21
// Enabling multidex support.
multiDexEnabled true
}
and try again

Categories

Resources