2017-07-25 35 views
-3

錯誤消息
`錯誤:執行失敗,對於任務 ':app:transformClassesWithJarMergingForDebug'。我得到執行時間上的錯誤

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: com/google/common/annotations/Beta.class`

的build.gradle(Module.app)

apply plugin: 'com.android.application' 

    android { 
compileSdkVersion 25 
buildToolsVersion "25.0.2" 
defaultConfig { 
    applicationId "com.example.jd.travelsdemo" 
    minSdkVersion 19 
    targetSdkVersion 25 
    multiDexEnabled true 
    versionCode 1 
    versionName "1.0" 
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
    configurations.all { 
     resolutionStrategy { 
      force 'com.google.code.findbugs:jsr305:1.3.9', 'com.google.code.findbugs:jsr305:2.0.1' 
     } 
    } 
} 
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.android.support:appcompat-v7:25.3.1' 
compile 'com.android.support:design:25.3.1' 
compile 'com.android.support:support-v4:25.3.1' 
compile 'com.android.support:cardview-v7:25.3.1' 
compile 'com.github.clans:fab:1.6.4' 
compile 'com.basgeekball:awesome-validation:2.0' 
//gmail api dependencies 
compile 'com.google.android.gms:play-services-auth:10.2.4' 
compile('com.google.api-client:google-api-client-android:1.22.0') { 
    exclude group: 'org.apache.httpcomponents' 
} 
compile('com.google.apis:google-api-services-gmail:v1-rev44-1.22.0') { 
    exclude group: 'org.apache.httpcomponents' 

} 

compile 'junit:junit:4.12' 
    } 
+0

您的第三方庫之一正在使用您引用的庫的不同版本。它應該警告你在android studio中存在不匹配。尋找你的依賴之一,被橙色/淺米色 – Doomsknight

+0

後輸出從'gradlew應用程序:依賴關係' – DeKaNszn

+0

輸出 – Jigish

回答

0

嘗試此通過使用以下代碼

packagingOptions { 
    exclude 'META-INF/DEPENDENCIES' 
    exclude 'META-INF/NOTICE' 
    exclude 'META-INF/LICENSE' 
    exclude 'META-INF/LICENSE.txt' 
    exclude 'META-INF/NOTICE.txt' 
    pickFirst 'META-INF/license.txt' 
     } 
+0

仍然會得到相同的錯誤 – Jigish

1
compile('com.google.api-client:google-api-client-android:1.22.0') { 
    exclude group: 'org.apache.httpcomponents' 
    exclude group:'com.google.guava' 
} 
compile('com.google.apis:google-api-services-gmail:v1-rev67-1.22.0') { 
    exclude group: 'org.apache.httpcomponents' 
    exclude group:'com.google.guava' 

} 

加入排除基團如上述排除複製的文件。