2017-06-17 50 views
1

我知道這個問題被問了好幾次。我一直在嘗試使用各種解決方案超過3個小時,但他們都沒有爲我工作。com.android.build.api.transform.TransformException:java.util.zip.ZipException:構建APK時重複條目

當我運行應用程序,它工作得很好,但是當我嘗試建立APK它給我以下錯誤:

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/android/gms/internal/zzcn$zza.class

我已經成功地邁出了構建之前我加火力的FCM通知。添加FCM後,我出現了dex錯誤,所以我必須添加對multidex的支持。我也在使用YouTube播放器的jar文件。

這是我的搖籃文件:

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' 

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


android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.3" 
    defaultConfig { 
     applicationId "com.sample.application" 
     minSdkVersion 15 
     targetSdkVersion 25 
     versionCode 1 
     versionName "1.0" 
     multiDexEnabled true 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

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('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
     transitive = true; 
    } 
    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:support-v4:25.3.1' 
    compile 'com.squareup.retrofit2:retrofit:2.3.0' 
    compile 'com.squareup.retrofit2:converter-gson:2.0.0' 
    compile 'com.squareup.picasso:picasso:2.5.2' 
    compile 'com.facebook.android:audience-network-sdk:4.+' 
    compile 'com.google.firebase:firebase-messaging:10.0.1' 
    compile 'com.android.support:multidex:1.0.1' 
    testCompile 'junit:junit:4.12' 
} 

apply plugin: 'com.google.gms.google-services' 

回答

1

的問題是,com.facebook.android:audience-network-sdk具有依賴性:play-services-ads:8.4.0不匹配10.0.1版本

取代:

compile 'com.facebook.android:audience-network-sdk:4.+' 
compile 'com.google.firebase:firebase-messaging:10.0.1' 

有:

compile ('com.facebook.android:audience-network-sdk:4.+'){ 
    exclude group: "com.google.android.gms" 
} 
compile 'com.google.android.gms:play-services-ads:10.0.1' 
compile 'com.google.firebase:firebase-messaging:10.0.1' 
+0

立即獲取此錯誤: '錯誤:(54,0)無法找到方法com.facebook.android:audience-network-sdk:4.23.0()參數[build_2yh3ngz08u69glzj42nk9uxyr $ _run_closure3 $ _closure10 @ 2d819344] on object類型爲org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.' –

相關問題