2016-03-08 150 views
2

首先,我想承認我知道大多數關於gradle問題的問題。這不是重複的。問題與其他問題類似,但所有解決方案都失敗當我添加谷歌播放服務廣告庫時發生問題。它的應用程序已經正確構建之前。在添加之後經典問題發生。在gradle上構建android應用程序

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-oracle/bin/java'' finished with non-zero exit value 1 
in some cases exit value was 3 

我曾與幾個模塊排除改變gradle這個文件很多次,擴大機器人工作室堆大小和許多其他的可能性。畢竟嘗試後,我無法弄清楚什麼是錯的。

搖籃文件:

buildscript { 
    repositories { 
     maven { url 'https://maven.fabric.io/public' } 
    } 

    dependencies { 
     classpath 'io.fabric.tools:gradle:1.+' 
    } 
} 
apply plugin: 'com.android.application' 
apply plugin: 'io.fabric' 
apply plugin: 'com.neenbedankt.android-apt' 
apply plugin: 'com.google.gms.google-services' 


repositories { 
    maven { url 'https://maven.fabric.io/public' } 
    maven { url "https://clojars.org/repo/" } 
    maven { url "https://jitpack.io" } 

} 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.2" 

    defaultConfig { 
     applicationId "xxx" 
     minSdkVersion 16 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
     multiDexEnabled true 
    } 

    dexOptions { 
     preDexLibraries = false 
    //I have also tried enlarging heap size here 
    } 

    buildTypes { 
     release { 
      shrinkResources true 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    packagingOptions { 
     exclude 'META-INF/DEPENDENCIES' 
     exclude 'META-INF/NOTICE' 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/LICENSE.txt' 
     exclude 'META-INF/NOTICE.txt' 
    } 
    lintOptions { 
     checkReleaseBuilds false 
    } 
} 

dependencies { 
    compile 'com.android.support:multidex:1.0.0' 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    apt "com.google.dagger:dagger-compiler:2.0.2" 
    // Needed for @Generated annotation (missing in Java <= 1.6; therefore, Android) 
    compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
     transitive = true; 
    } 
    //ads lib ruined building 
    compile 'com.google.android.gms:play-services-ads:8.3.0' 
    compile("com.google.android.gms:play-services-gcm:8.3.0") { 
     exclude module: 'httpclient' //by artifact name 
     exclude group: 'org.apache.httpcomponents' //by group 
     exclude group: 'org.apache.httpcomponents', module: 'httpclient' //by both name and group 
    } 
    compile 'com.facebook.android:facebook-android-sdk:4.0.0' 
    compile 'com.google.guava:guava:19.0' 
    compile 'com.android.support:appcompat-v7:23.1.1' 
    compile 'com.android.support:design:23.1.1' 
    compile 'com.jakewharton:butterknife:7.0.1' 
    compile 'com.squareup.okhttp:okhttp:2.7.4' 
    compile('com.squareup.retrofit2:retrofit:2.0.0-beta4') { 
     exclude module: 'okhttp' 
    } 
    compile 'com.squareup.retrofit2:converter-gson:2.0.0-beta4' 
    compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0-beta4' 
    compile 'com.squareup.okhttp3:logging-interceptor:3.0.1' 
    compile 'com.google.code.gson:gson:2.5' 
    compile 'com.google.dagger:dagger:2.0.2' 
    compile('com.google.apis:google-api-services-youtube:v3-rev162-1.21.0') { 
     exclude group: 'com.google.guava' 
     exclude module: 'httpclient' //by artifact name 
     exclude group: 'org.apache.httpcomponents' //by group 
     exclude group: 'org.apache.httpcomponents', module: 'httpclient' //by both name and group 
    } 
    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5' 
    compile 'io.reactivex:rxandroid:1.1.0' 
    compile 'io.reactivex:rxjava:1.1.0' 
    compile 'com.github.orhanobut:logger:1.12' 
    compile 'javax.annotation:jsr250-api:1.0' 
    compile 'frankiesardo:icepick:3.1.0' 
    apt 'frankiesardo:icepick-processor:3.1.0' 
} 

我不希望使用谷歌整體播放服務庫。當發生

搖籃控制檯輸出錯誤:

:app:transformClassesWithDexForDebug 
Uncaught translation error: java.util.concurrent.ExecutionException: 
java.lang.OutOfMemoryError: GC overhead limit exceeded Uncaught translation error: 
java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: 
GC overhead limit exceeded 2 errors; aborting FAILED 
+1

「在添加經典問題後」 - 通常,真正的問題在Gradle控制檯的某個地方描述,而不是您在問題中包含的內容。請編輯您的問題以包含此版本的整個Gradle控制檯輸出,而不僅僅是這幾行。 – CommonsWare

+0

:app:transformClassesWithDexForDebug 未捕獲的轉換錯誤:java.util.concurrent.ExecutionException:java.lang.OutOfMemoryError:超出GC開銷限制 未捕獲的轉換錯誤:java.util.concurrent.ExecutionException:java.lang.OutOfMemoryError:GC開銷限制超過 2個錯誤;墮胎 失敗 就是這樣。在添加廣告庫之前,一切正常。 – Nihilus13

+1

http://stackoverflow.com/questions/30045417/android-studio-gradle-could-not-reserve-enough-space-for-object-heap – CommonsWare

回答

0

根據miva2cricket_007意見 - 他們擁有的權利。庫太多了。我刪除了

compile 'com.squareup.okhttp:okhttp:2.7.4' 

來自gradle構建文件和應用程序已構建。

相關問題