Android studio gradle例外(sdk 23.2.0,改装2,google-service 8.4)

时间:2016-02-25 18:26:15

标签: android

在构建项目期间,我遇到了一个gradle构建错误:

Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded

1错误;中止

为什么会这样?

完整日志低于

我的gradle是:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.2.0'
    compile 'com.android.support:design:23.2.0'
    compile 'com.android.support:support-v4:23.2.0'
    compile 'com.android.support:cardview-v7:23.2.0'
    compile 'com.android.support:recyclerview-v7:23.2.0'

    compile 'com.j256.ormlite:ormlite-android:4.48'
    compile 'com.squareup.retrofit2:retrofit:2.0.0-beta4'
    compile 'com.squareup.okhttp3:okhttp:3.0.0'
    compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4'

    compile 'com.github.bumptech.glide:glide:3.6.0'
    compile 'com.github.nirhart:parallaxscroll:1.0'

    compile 'com.facebook.android:facebook-android-sdk:4.1.0'
    compile 'com.google.android.gms:play-services:8.4.0'

    compile 'de.hdodenhof:circleimageview:1.3.0'
    compile 'com.appbrain:appbrain-applift-sdk:10.51'
    compile 'com.android.support:multidex:1.0.1'
}

返回此例外:

Information:Gradle tasks [:app:assembleDebug]
:app:preBuild UP-TO-DATE
:app:preDebugBuild UP-TO-DATE
:app:checkDebugManifest
:app:preReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2320Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72320Library UP-TO-DATE
:app:prepareComAndroidSupportCardviewV72320Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2320Library UP-TO-DATE
:app:prepareComAndroidSupportMediarouterV72300Library UP-TO-DATE
:app:preDebugAndroidTestBuild UP-TO-DATE
:app:prepareComAndroidSupportMultidex101Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72320Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42320Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2320Library UP-TO-DATE
:app:prepareComFacebookAndroidFacebookAndroidSdk410Library UP-TO-DATE
:app:prepareComGithubNirhartParallaxscroll10Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAds840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAnalytics840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppindexing840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppinvite840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAppstate840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesAuth840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBase840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesBasement840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesCast840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesDrive840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesFitness840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGames840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesGcm840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesIdentity840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesLocation840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMaps840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesMeasurement840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesNearby840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPanorama840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesPlus840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesSafetynet840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesVision840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWallet840Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServicesWearable840Library UP-TO-DATE
:app:prepareDeHdodenhofCircleimageview130Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:compileDebugJavaWithJavac UP-TO-DATE
:app:compileDebugNdk UP-TO-DATE
:app:compileDebugSources UP-TO-DATE
:app:transformClassesWithJarMergingForDebug UP-TO-DATE
:app:collectDebugMultiDexComponents UP-TO-DATE
:app:transformClassesWithMultidexlistForDebug UP-TO-DATE
:app:transformClassesWithDexForDebug
Uncaught translation error: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
1 error; aborting
Error:Execution failed for task ':tbkha:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/usr/lib/jvm/java-8-openjdk-amd64/bin/java'' finished with non-zero exit value 1
Information:BUILD FAILED
Information:Total time: 2 mins 39.656 secs
Information:1 error
Information:0 warnings
Information:See complete output in console

我如何解决这个问题?

1 个答案:

答案 0 :(得分:3)

java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded    
Error:Execution failed for task ':tbkha:transformClassesWithDexForDebug'.

看起来这是因为gradle在将java代码转换为dex时内存不足。

您可以通过更改' gradle-wrapper.properties'来增加分配给gradle的内存。 (通常位于/{project_name}/gradle/wrapper/gradle-wrapper.properties)。

您需要做的就是添加以下几行

org.gradle.jvmargs=-Xmx1024m

修改

您还可以在build build.gradle中改进javaMaxHeapSize

android {
   dexOptions {
         javaMaxHeapSize = "4g"
              }
         }