2017-07-27 99 views
0

當我嘗試生成簽名的APK時,出現此錯誤。錯誤:任務':app:transformClassesWithDexForRelease'的執行失敗。同時生成APK

錯誤

Error:Execution failed for task ':app:transformClassesWithDexForRelease'. com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzaj;

的build.gradle

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.2" 
    defaultConfig { 
     applicationId "com.comp.app" 
     minSdkVersion 15 
     targetSdkVersion 25 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    buildTypes.each { 
     it.buildConfigField 'String', 'ApiKey', keystoreProperties['Api_Key'] 

    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile files('libs/YouTubeAndroidPlayerApi.jar') 
    compile 'com.android.support:appcompat-v7:25.3.1' 
    compile 'com.android.support:design:25.3.1' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
    compile 'com.android.support:recyclerview-v7:25.3.1' 
    compile 'com.android.support:cardview-v7:25.3.1' 
    compile 'com.google.firebase:firebase-messaging:11.0.2' 
    compile 'com.facebook.android:facebook-android-sdk:4.23.0' 
    compile 'com.facebook.android:audience-network-sdk:4.24.0' 
    compile 'com.google.code.gson:gson:2.7' 
    compile 'de.hdodenhof:circleimageview:2.1.0' 
    compile 'com.squareup.retrofit2:converter-gson:2.3.0' 
    compile 'com.squareup.retrofit2:retrofit:2.3.0' 
    compile 'com.squareup.picasso:picasso:2.5.2' 
    testCompile 'junit:junit:4.12' 
} 
apply plugin: 'com.google.gms.google-services' 

項目一級的build.gradle

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.3.3' 
     classpath 'com.google.gms:google-services:3.1.0' 

     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
     mavenCentral() 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 

的Classpath

compile - Classpath for compiling the main sources. 
+--- com.android.support:appcompat-v7:25.3.1 
| +--- com.android.support:support-annotations:25.3.1 
| +--- com.android.support:support-v4:25.3.1 
| | +--- com.android.support:support-compat:25.3.1 
| | | \--- com.android.support:support-annotations:25.3.1 
| | +--- com.android.support:support-media-compat:25.3.1 
| | | +--- com.android.support:support-annotations:25.3.1 
| | | \--- com.android.support:support-compat:25.3.1 (*) 
| | +--- com.android.support:support-core-utils:25.3.1 
| | | +--- com.android.support:support-annotations:25.3.1 
| | | \--- com.android.support:support-compat:25.3.1 (*) 
| | +--- com.android.support:support-core-ui:25.3.1 
| | | +--- com.android.support:support-annotations:25.3.1 
| | | \--- com.android.support:support-compat:25.3.1 (*) 
| | \--- com.android.support:support-fragment:25.3.1 
| |   +--- com.android.support:support-compat:25.3.1 (*) 
| |   +--- com.android.support:support-media-compat:25.3.1 (*) 
| |   +--- com.android.support:support-core-ui:25.3.1 (*) 
| |   \--- com.android.support:support-core-utils:25.3.1 (*) 
| +--- com.android.support:support-vector-drawable:25.3.1 
| | +--- com.android.support:support-annotations:25.3.1 
| | \--- com.android.support:support-compat:25.3.1 (*) 
| \--- com.android.support:animated-vector-drawable:25.3.1 
|   \--- com.android.support:support-vector-drawable:25.3.1 (*) 
+--- com.android.support:design:25.3.1 
| +--- com.android.support:support-v4:25.3.1 (*) 
| +--- com.android.support:appcompat-v7:25.3.1 (*) 
| +--- com.android.support:recyclerview-v7:25.3.1 
| | +--- com.android.support:support-annotations:25.3.1 
| | +--- com.android.support:support-compat:25.3.1 (*) 
| | \--- com.android.support:support-core-ui:25.3.1 (*) 
| \--- com.android.support:transition:25.3.1 
|   +--- com.android.support:support-annotations:25.3.1 
|   \--- com.android.support:support-v4:25.3.1 (*) 
+--- com.android.support.constraint:constraint-layout:1.0.2 
| \--- com.android.support.constraint:constraint-layout-solver:1.0.2 
+--- com.android.support:recyclerview-v7:25.3.1 (*) 
+--- com.android.support:cardview-v7:25.3.1 
| \--- com.android.support:support-annotations:25.3.1 
+--- com.google.firebase:firebase-messaging:11.0.2 
| +--- com.google.firebase:firebase-iid:[11.0.2] -> 11.0.2 
| | +--- com.google.android.gms:play-services-basement:[11.0.2] -> 11.0.2 
| | | \--- com.android.support:support-v4:25.2.0 -> 25.3.1 (*) 
| | \--- com.google.firebase:firebase-common:[11.0.2] -> 11.0.2 
| |   +--- com.google.android.gms:play-services-basement:[11.0.2] -> 11.0.2 (*) 
| |   \--- com.google.android.gms:play-services-tasks:[11.0.2] -> 11.0.2 
| |    \--- com.google.android.gms:play-services-basement:[11.0.2] -> 11.0.2 (*) 
| +--- com.google.android.gms:play-services-basement:[11.0.2] -> 11.0.2 (*) 
| \--- com.google.firebase:firebase-common:[11.0.2] -> 11.0.2 (*) 
+--- com.facebook.android:facebook-android-sdk:4.23.0 
| +--- com.android.support:support-v4:25.3.1 (*) 
| +--- com.android.support:appcompat-v7:25.3.1 (*) 
| +--- com.android.support:cardview-v7:25.3.1 (*) 
| +--- com.android.support:customtabs:25.3.1 
| | +--- com.android.support:support-compat:25.3.1 (*) 
| | \--- com.android.support:support-annotations:25.3.1 
| \--- com.parse.bolts:bolts-android:1.4.0 
|   +--- com.parse.bolts:bolts-tasks:1.4.0 
|   \--- com.parse.bolts:bolts-applinks:1.4.0 
|    \--- com.parse.bolts:bolts-tasks:1.4.0 
+--- com.facebook.android:audience-network-sdk:4.24.0 
| +--- com.android.support:appcompat-v7:25.0.0 -> 25.3.1 (*) 
| +--- com.android.support:recyclerview-v7:25.0.0 -> 25.3.1 (*) 
| +--- com.android.support:support-annotations:25.0.0 -> 25.3.1 
| +--- com.android.support:support-v4:25.0.0 -> 25.3.1 (*) 
| +--- com.google.android.exoplayer:exoplayer:r2.0.3 
| | \--- com.android.support:support-annotations:24.2.0 -> 25.3.1 
| \--- com.google.android.gms:play-services-ads:8.4.0 
|   \--- com.google.android.gms:play-services-basement:8.4.0 -> 11.0.2 (*) 
+--- com.google.code.gson:gson:2.7 
+--- de.hdodenhof:circleimageview:2.1.0 
+--- com.squareup.retrofit2:converter-gson:2.3.0 
| +--- com.squareup.retrofit2:retrofit:2.3.0 
| | \--- com.squareup.okhttp3:okhttp:3.8.0 
| |   \--- com.squareup.okio:okio:1.13.0 
| \--- com.google.code.gson:gson:2.7 
+--- com.squareup.retrofit2:retrofit:2.3.0 (*) 
+--- com.squareup.picasso:picasso:2.5.2 
+--- com.android.support:multidex:1.0.1 
\--- com.google.firebase:firebase-core:11.0.2 
    \--- com.google.firebase:firebase-analytics:[11.0.2] -> 11.0.2 
      +--- com.google.firebase:firebase-analytics-impl:[11.0.2] -> 11.0.2 
      | +--- com.google.android.gms:play-services-basement:[11.0.2] -> 11.0.2 (*) 
      | +--- com.google.firebase:firebase-iid:[11.0.2] -> 11.0.2 (*) 
      | +--- com.google.firebase:firebase-common:[11.0.2] -> 11.0.2 (*) 
      | \--- com.google.android.gms:play-services-tasks:[11.0.2] -> 11.0.2 (*) 
      +--- com.google.android.gms:play-services-basement:[11.0.2] -> 11.0.2 (*) 
      \--- com.google.firebase:firebase-common:[11.0.2] -> 11.0.2 (*) 
+0

發佈您的'gradlew app:dependencies' – DeKaNszn

+0

檢查問題 –

+0

您只發布了直接依賴關係。但是你關於傳遞依賴關係的問題。 – DeKaNszn

回答

0

嘗試刪除

compile files('libs/YouTubeAndroidPlayerApi.jar') 

因爲你已經添加YouTubeAndroidPlayerApi.jar與線

compile fileTree(include: ['*.jar'], dir: 'libs') 
+0

仍然同樣的錯誤 –

+0

我不知道它是否有幫助,但你可以請嘗試使用Facebook-android-sdk相同的版本作爲audience-network-sdk? – Yury

+0

它沒有工作 –

0

添加在你的依賴: compile 'com.google.android.gms:play-services-ads:11.0.2'

這條線將迫使新的廣告庫。您的com.google.firebase:firebase-messaging部隊com.google.android.gms:play-services-basement:11.0.2

+0

是的,我想通了。其實它由排除組:「com.google.android.gms」起作用。 –

相關問題