2016-02-13 63 views
0

我的項目工作正常,直到我添加了排雷庫。然後,它開始給我這樣一個錯誤:Android Studio Gradle錯誤「Multiple dex files define ...」

Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.> java.util.zip.ZipException: duplicate entry: com/android/volley/AuthFailureError.class

我應該怎麼做才能解決這個錯誤?

我的應用gradle這個低於

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.1" 
    useLibrary 'org.apache.http.legacy' 

    defaultConfig { 
     applicationId "com.snsepro.mym" 
     minSdkVersion 16 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
     multiDexEnabled = true 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    dexOptions { 
     javaMaxHeapSize "4g" 
    } 

    packagingOptions { 
     exclude 'META-INF/DEPENDENCIES' 
     exclude 'META-INF/NOTICE' 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/LICENSE.txt' 
     exclude 'META-INF/NOTICE.txt' 
    } 
} 
ext { 
    supportLibVersion = '23.1.1' // variable that can be referenced to keep support libs consistent 
} 

repositories { 
    maven { url 'https://zendesk.artifactoryonline.com/zendesk/repo' } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile files('libs/gcm.jar') 
    compile files('libs/gcm-src.jar') 
    compile files('libs/picasso-2.5.2.jar') 
    compile files('libs/jsoup-1.7.3.jar') 
    compile files('libs/gson-2.2.4.jar') 
    compile files('libs/volley.jar') 
    compile files('libs/cometchat-sdk.jar') 
    compile 'com.android.support:appcompat-v7:23.1.1' 
    compile 'com.android.support:recyclerview-v7:23.1.1' 
    compile 'com.prolificinteractive:material-calendarview:0.7.0' 
    compile 'it.sephiroth.android.library.targettooltip:target-tooltip-library:[email protected]' 
    compile 'com.github.siyamed:android-shape-imageview:[email protected]' 
    compile 'com.balysv:material-ripple:1.0.2' 
    compile 'com.isseiaoki:simplecropview:1.0.8' 
    compile 'se.emilsjolander:stickylistheaders:2.7.0' 
    compile 'com.github.ksoichiro:android-observablescrollview:1.6.0' 
    compile 'com.android.support:design:23.1.1' 
    compile 'com.android.support:multidex:1.0.0' 
    compile 'com.google.android.gms:play-services:8.4.0' 
    compile 'com.google.android.gms:play-services-gcm:8.4.0' 
    compile 'com.android.support:cardview-v7:23.1.1' 
    compile 'com.google.android.gms:play-services-ads:8.4.0' 
    compile 'com.google.android.gms:play-services-identity:8.4.0' 
    compile('com.zopim.android:sdk:1.1.1') { 
     exclude group: 'com.squareup.picasso' 
    } 
} 

這裏添加bulild.gradle

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.1" 
    useLibrary 'org.apache.http.legacy' 

    defaultConfig { 
     applicationId "com.snsepro.mym" 
     minSdkVersion 16 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
     multiDexEnabled = true 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    dexOptions { 
     javaMaxHeapSize "4g" 
    } 

    packagingOptions { 
     exclude 'META-INF/DEPENDENCIES' 
     exclude 'META-INF/NOTICE' 
     exclude 'META-INF/LICENSE' 
     exclude 'META-INF/LICENSE.txt' 
     exclude 'META-INF/NOTICE.txt' 
    } 
} 
ext { 
    supportLibVersion = '23.1.1' // variable that can be referenced to keep support libs consistent 
} 

repositories { 
    maven { url 'https://zendesk.artifactoryonline.com/zendesk/repo' } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    compile files('libs/gcm.jar') 
    compile files('libs/gcm-src.jar') 
    compile files('libs/picasso-2.5.2.jar') 
    compile files('libs/jsoup-1.7.3.jar') 
    compile files('libs/gson-2.2.4.jar') 
    compile files('libs/volley.jar') 
    compile files('libs/cometchat-sdk.jar') 
    compile 'com.android.support:appcompat-v7:23.1.1' 
    compile 'com.android.support:recyclerview-v7:23.1.1' 
    compile 'com.prolificinteractive:material-calendarview:0.7.0' 
    compile 'it.sephiroth.android.library.targettooltip:target-tooltip-library:[email protected]' 
    compile 'com.github.siyamed:android-shape-imageview:[email protected]' 
    compile 'com.balysv:material-ripple:1.0.2' 
    compile 'com.isseiaoki:simplecropview:1.0.8' 
    compile 'se.emilsjolander:stickylistheaders:2.7.0' 
    compile 'com.github.ksoichiro:android-observablescrollview:1.6.0' 
    compile 'com.android.support:design:23.1.1' 
    compile 'com.android.support:multidex:1.0.0' 
    compile 'com.google.android.gms:play-services:8.4.0' 
    compile 'com.google.android.gms:play-services-gcm:8.4.0' 
    compile 'com.android.support:cardview-v7:23.1.1' 
    compile 'com.google.android.gms:play-services-ads:8.4.0' 
    compile 'com.google.android.gms:play-services-identity:8.4.0' 
    compile('com.zopim.android:sdk:1.1.1') { 
     exclude group: 'com.squareup.picasso' 
    } 
    compile 'com.mcxiaoke.volley:library-aar:1.0.1' 
} 
+0

你正在編譯'libs'文件夾中的每個jar文件兩次。這行'編譯fileTree(dir:'libs',包括:''.jar'])'處理* libs'文件夾中的每個* jar,你不需要編譯文件('libs/..' ) –

+0

另外,當你編譯com.mcxiaoke.volley時,你不需要'volley.jar':library:1.0.19'' –

+0

yes是解決我已經刪除了一個 –

回答

0

凌空庫庫什麼是你的編譯文件( '庫/ volley.jar')如果它是一樣的,你一定會得到這個錯誤。在這種情況下,嘗試刪除任何一個。

相關問題