2016-04-24 50 views
0

我收到以下錯誤搖籃建立運行錯誤(DebugUtils.class)Android Studio中1.5

錯誤:執行失敗的任務

:app:transformClassesWithJarMergingForDebug. com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: android/support/v4/util/DebugUtils.class

我找遍了整個一天,但未能找到一個適當的答案將解決我的問題。

我的應用程序的gradle bulid

apply plugin: 'com.android.application' 

android { 
compileSdkVersion 23 
buildToolsVersion "23.0.1" 

defaultConfig { 
    applicationId "com.project.test" 
    multiDexEnabled true 
    minSdkVersion 17 
    targetSdkVersion 23 
    versionCode 1 
    versionName "1.0" 
} 

dexOptions { 
    javaMaxHeapSize "4g" 
} 

buildTypes { 
    release { 
     minifyEnabled true 
     shrinkResources true 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 
} 

//依賴文件

dependencies 
{ 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.1.1' 
    compile 'com.android.support:design:23.1.1' 
    compile 'com.google.android.gms:play-services-ads:+' 
    compile 'com.google.android.gms:play-services-identity:+' 
    compile 'com.google.android.gms:play-services-gcm:+' 
    compile files('libs/android-support-v4.jar') 
    compile 'com.github.JakeWharton:ViewPagerIndicator:2.4.1' 
} 

我試圖清理和重建,但也不能正常工作。 請幫忙。提前致謝。

+0

你有沒有試圖消除'編譯文件(「庫/ android-support-v4.jar')'從依賴關係行嗎?它似乎已經作爲fileTree行中的依賴項添加了。 –

+0

是的,這也是阿德里安。不工作。 – Sethuraman

回答

0

當兩次添加同一個類時,會發生此問題。

在您的項目中,您將多次添加support-v4庫。

  • 刪除android-support-v4.jar從libs文件夾
  • 刪除此行compile files('libs/android-support-v4.jar')
  • 改變圖書館的com.github.JakeWharton:ViewPagerIndicator:2.4.1「的依賴,因爲它使用一箇舊的支持,v4.jar

用途:

compile ('com.github.JakeWharton:ViewPagerIndicator:2.4.1') { 
      exclude module: 'support-v4' 
} 
+0

感謝噸mariotti :)它的工作! – Sethuraman

0

經過一番研究,它接縫com.github.JakeWharton:ViewPagerIndicator:2.4.1already importingandroid-support-v4.jar,從這裏你的重複錯誤。爲了解決這個問題,我建議你做以下修改:

  • 從庫刪除文件夾android-support-v4.jar
  • 從gradle這個文件中的行compile files('libs/android-support-v4.jar')刪除。

希望它可以解決您的問題。