Android Studio:超出 GC 开销限制 [英] Android Studio: GC overhead limit exceeded

查看:30
本文介绍了Android Studio:超出 GC 开销限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Error:Execution failed for task ':app:transformClassesWithDexForDebug'.
> java.lang.OutOfMemoryError: GC overhead limit exceeded

尝试过:

dexOptions {
    javaMaxHeapSize "4g"
}

这似乎是唯一可用的在线解决方案.

That seems to be the only solution available online.

但它仍然超过了第二次构建的限制,除非我杀死工作室任务并重新启动,这使它第一次工作.

But still it exceeds the limit on 2nd build, unless I kill the studio task and restart, which makes it work for the 1st time.

build.gradle 中的依赖肯定不会太多

Definitely not many dependencies in the build.gradle

build.grade

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.xxxxx.android"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 8
        versionName "1.3"
    }

    dexOptions {
        javaMaxHeapSize "4g"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:23.1.1'
    compile 'com.android.support:recyclerview-v7:23.1.1'
    compile 'com.android.support:design:23.1.1'
    compile 'com.jakewharton:butterknife:6.1.0'
    compile 'com.squareup.okhttp:okhttp:2.3.0'
    compile 'com.squareup.okhttp:okhttp-urlconnection:2.3.0'
    compile 'com.squareup.retrofit:retrofit:1.9.0'
    compile 'de.greenrobot:eventbus:2.4.0'
    compile 'com.google.android.gms:play-services-location:+'
}

推荐答案

增加IDE内存(file studio.vmoptions)

Increase the IDE memory (file studio.vmoptions)

http://tools.android.com/tech-docs/configuration

我的设置:

-Xms256m
-Xmx3080m
-XX:MaxPermSize=350m
-XX:ReservedCodeCacheSize=225m
-XX:+UseCompressedOops

这篇关于Android Studio:超出 GC 开销限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆