2016-08-22 47 views
0

每當我嘗試運行我的項目時,都會遇到此問題。
我收到此錯誤:ZipExcepton:重複條目:com/google/android/gms/internal/zzpi.class

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

這裏是我的構建腳本:

buildscript { 
    repositories { 
     maven { url 'https://maven.fabric.io/public' } 
    } 
    dependencies { 
     // The Fabric Gradle plugin uses an open ended version to react 
     // quickly to Android tooling updates 
     classpath 'io.fabric.tools:gradle:1.15.2' 
    } 
} 
apply plugin: 'com.android.application' 
//Put Fabric plugin after Android plugin 

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


dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    compile files('libs/commons-collections4-4.0.jar') 
    compile files('libs/YouTubeAndroidPlayerApi.jar') 
    compile files('libs/graphview-3.1.jar') 
    testCompile 'junit:junit:4.12' 
    compile project(':progresslibrary') 
    compile files('libs/gson-2.6.2.jar') 
    compile('com.crashlytics.sdk.android:crashlytics:[email protected]') { 
     transitive = true; 
    } 
    apt 'com.github.hotchemi:permissionsdispatcher-processor:2.1.2' 
    apt 'com.github.hotchemi:permissionsdispatcher-processor:2.1.2' 



    compile 'com.android.support:multidex:1.0.0' 
    compile 'com.hrules:charter:1.4.0' 
    compile 'com.github.hotchemi:permissionsdispatcher:2.1.2' 
    //noinspection GradleCompatible 
    compile 'com.google.android.gms:play-services-analytics:8.4.0' 
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.15' 
    compile 'com.android.support:multidex:1.0.0' 
    compile 'com.hrules:charter:1.4.0' 
    compile 'com.google.android.gms:play-services-analytics:8.4.0' 
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.15' 
    compile 'com.github.hotchemi:permissionsdispatcher:2.1.2' 
    compile 'com.amazonaws:aws-android-sdk-core:2.+' 
    compile 'com.amazonaws:aws-android-sdk-s3:2.+' 
    compile 'eu.the4thfloor.volley:com.android.volley:2015.05.28' 
    compile 'com.facebook.android:facebook-android-sdk:4.0.0' 
    compile 'com.snappydb:snappydb-lib:0.5.2' 
    compile 'com.google.android.gms:play-services-auth:9.4.0' 
    compile 'com.google.android.gms:play-services-plus:8.4.0' 
    compile 'com.google.android.gms:play-services-gcm:9.4.0' 
    compile 'com.squareup.picasso:picasso:2.5.2' 
    compile 'com.google.android.gms:play-services-location:8.4.0' 
    compile 'com.wdullaer:materialdatetimepicker:2.2.0' 
    compile 'com.oguzdev:CircularFloatingActionMenu:1.0.2' 
    compile 'com.shamanland:fab:0.0.8' 
    compile 'org.florescu.android.rangeseekbar:rangeseekbar-library:0.3.0' 
    compile 'com.android.support:design:23.2.0' 
    compile 'com.android.support:support-v4:23.2.0' 
    compile 'com.android.support:recyclerview-v7:23.2.0' 
    compile 'com.android.support:cardview-v7:23.2.0' 
    compile 'org.jsoup:jsoup:1.9.1' 
    compile 'com.flurry.android:analytics:6.2.0' 
    compile 'com.google.android.gms:play-services-fitness:8.4.0' 
    compile 'com.google.android.gms:play-services-appindexing:8.4.0' 
    compile 'com.github.danielemaddaluno.androidupdatechecker:library:1.0.2' 
    compile 'com.astuetz:pagerslidingtabstrip:1.0.1' 
} 

android { 
    packagingOptions { 
     exclude 'META-INF/NOTICE.txt' 
     exclude 'META-INF/LICENSE.txt' 
    } 
} 
apply plugin: 'build-announcements' 

請告訴我什麼是錯我的構建腳本

+0

你是包括了太多的依賴(這是在應用程序開發的反模式)。甚至有重複的行... –

+0

我可以告訴你,問題是谷歌播放服務之一。 –

+0

@ cricket_007我該如何解決它? –

回答

0

快速瀏覽,我可以告訴您在Google Play服務中存在問題。我會猜測這些都需要是相同的版本(在這裏按同一版本分組)。

compile 'com.google.android.gms:play-services-analytics:8.4.0' 
compile 'com.google.android.gms:play-services-plus:8.4.0' 
compile 'com.google.android.gms:play-services-location:8.4.0' 
compile 'com.google.android.gms:play-services-fitness:8.4.0' 
compile 'com.google.android.gms:play-services-appindexing:8.4.0' 

compile 'com.google.android.gms:play-services-auth:9.4.0' 
compile 'com.google.android.gms:play-services-gcm:9.4.0' 

爲了有效地做到這一點,您可以在您定義的ext塊搖籃文件保存的版本號一致。

附加說明:這條線compile fileTree(include: ['*.jar'], dir: 'libs') ......它說編譯所有 JAR文件中libs/目錄中,因此,這些線是毫無意義的,而你試圖找出其中的錯誤時,你可以刪除它們。

compile files('libs/commons-collections4-4.0.jar') 
compile files('libs/YouTubeAndroidPlayerApi.jar') 
compile files('libs/graphview-3.1.jar') 
compile files('libs/gson-2.6.2.jar') 

樣品build.gradle

ext { 
    // Variables to keep libraries consistent 
    supportLibrary = "23.2.0" 
    googlePlayServicesVersion = '9.4.0' 

    // Support Libraries dependencies 
    supportDependencies = [ 
      design   :   "com.android.support:design:${supportLibrary}", 
      recyclerView  :   "com.android.support:recyclerview-v7:${supportLibrary}", 
      cardView   :   "com.android.support:cardview-v7:${supportLibrary}", 
      appCompatV7  :   "com.android.support:appcompat-v7:${supportLibrary}" 
    ] 

    googlePlayServicesDepends = [ 
      analytics : "com.google.android.gms:play-services-analytics:${googlePlayServicesVersion}" 
      plus  : "com.google.android.gms:play-services-plus:${googlePlayServicesVersion}" 
      location : "com.google.android.gms:play-services-location:${googlePlayServicesVersion}" 
      fitness  : "com.google.android.gms:play-services-fitness:${googlePlayServicesVersion}" 
      appindexing : "com.google.android.gms:play-services-appindexing:${googlePlayServicesVersion}" 
      auth  : "com.google.android.gms:play-services-auth:${googlePlayServicesVersion}" 
      gcm   : "com.google.android.gms:play-services-gcm:${googlePlayServicesVersion}" 
    ] 

} 

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

    // compile supportDependencies.appCompatV7 
    // compile supportDependencies.recyclerView 

    // recommended - includes those above 
    compile supportDependencies.design 

    // extras 
    compile supportDependencies.cardView 

    // The correct Volley library 
    compile 'com.android.volley:volley:1.0.0' 

    compile 'com.squareup.picasso:picasso:2.5.2' 
    compile "com.google.code.gson:gson:2.6.2" 

    // Google Play Services 
    compile googlePlayServicesDepends.location 
    // TODO: Add others 

}