0

I have this build.gradle file :

    apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"

    defaultConfig {
        applicationId "com.example.---"
        minSdkVersion 16
        targetSdkVersion 24
        multiDexEnabled true
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.google.android.gms:play-services:9.4.0'
    compile 'com.android.volley:volley:1.0.0'
    compile 'com.android.support:design:24.1.1'
    compile 'com.jpardogo.materialtabstrip:library:1.1.0'
    compile 'com.android.support:support-v4:24.1.1'
    compile 'com.google.android.gms:play-services:9.4.0'
}

When I build the gradle after loading I receive this error :

    Error:Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
Error:Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
Error:2 errors; aborting
:app:transformClassesWithDexForDebug FAILED
Error:Execution failed for task ':app: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 'C:\Program Files\Java\jdk1.8.0_77\bin\java.exe'' finished with non-zero exit value 1

How can I solve it?

xdevs23
  • 3,824
  • 3
  • 20
  • 33
Alessandro Zago
  • 793
  • 3
  • 12
  • 33

3 Answers3

2

Try to add the following into android of your build.gradle:

dexOptions {
    javaMaxHeapSize "4g"
}

Also look here for further information.

Community
  • 1
  • 1
UeliDeSchwert
  • 1,146
  • 10
  • 23
0

Applications running on API Level 11+ can have android:largeHeap="true" on the element in the manifest to request a larger-than-normal heap size, and getLargeMemoryClass() on ActivityManager will tell you how big that heap is. However: This only works on API Level 11+ (i.e., Honeycomb and beyond) There is no guarantee how large the large heap will be The user will perceive your large-heap request, because it will force their other apps out of RAM terminate other apps' processes to free up system RAM for use by your large heap Because of #3, and the fact that I expect that android:largeHeap will be abused, support for this may be abandoned in the future, or the user may be warned about this at install time (e.g., you will need to request a special permission for it) Presently, this feature is lightly documented

Sangram Haladkar
  • 707
  • 9
  • 22
0

look at gradle.properties file in project then you can see:

Specifies the JVM arguments used for the daemon process. The setting is particularly useful for tweaking memory settings. Default value: -Xmx10248m -XX:MaxPermSize=256m

org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8

You can change it to avoid out of memory

Community
  • 1
  • 1