java.lang.OutOfMemoryError:执行android项目时,超出了GC开销限制面临此错误

时间:2016-04-18 18:26:52

标签: java android android-studio build.gradle

以下是app.gradle文件的代码。我个人的项目模块完美地工作,但在单个应用程序中组合每个模块时,我收到此错误。我已经为Android智能手机制作了这个应用程序。

哪些必要的库应包含哪些内容?我已阅读有关此错误并已启用multiDexEnabled并已导入com.android.support:multidex:1.0.1但仍会收到此错误。

apply plugin: 'com.android.application'

android 
{
compileSdkVersion 23
buildToolsVersion "23.0.2"

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

}
repositories {
maven {
    url     'https://download.01.org/crosswalk/releases/crosswalk/android/maven2'
}
}

dependencies 
{
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'


compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.mcxiaoke.volley:library-aar:1.0.0'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.google.maps.android:android-maps-utils:0.4+'
compile 'com.google.android.gms:play-services-appindexing:8.1.0'
compile 'org.xwalk:xwalk_core_library:17.46.448.10'
compile 'com.android.support:multidex:1.0.1'
}

编译Android项目时出现此错误。

java.lang.OutOfMemoryError: GC overhead limit exceeded
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 'C:\Program
Files\Java\jdk1.7.0_25\bin\java.exe'' finished with non-zero exit value 3

1 个答案:

答案 0 :(得分:2)

尝试将此添加到您的构建文件中。

dexOptions {
        javaMaxHeapSize "4g"
}