本文介绍了Android Studio Gradle错误“Multiple dex files define ...”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的项目工作正常,直到我添加了排球库。然后,它开始给我一个这样的错误:我应该修正这个错误吗?
我的应用程序gradle在
apply plugin:'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion23.0.1
useLibrary'org.apache.http.legacy '
defaultConfig {
applicationIdcom.snsepro.mym
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName1.0
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'p roguard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize4g
}
packagingOptions {
exclude 'META-INF / DEPENDENCIES'
排除'META-INF /通知'
排除'META-INF / LICENSE'
排除'META-INF / LICENSE.txt'
排除'META-INF / NOTICE.txt'
}
}
ext {
supportLibVersion = '23 .1.1'//可以被引用以保持支持库一致的变量
存储库{
maven {url'https://zendesk.artifactoryonline.com/zendesk/repo'}
}
依赖关系{
编译fileTree(dir:'libs',include:['* .jar'])
编译文件('libs / gcm.jar')
编译文件('libs / gcm
编译文件('libs / picasso-2.5.2.jar')
编译文件('libs / jsoup-1.7.3.jar')
编译文件('libs / gson-2.2.4.jar')
编译文件( libs / volley.jar')
编译文件('libs / cometchat-sdk.jar')
编译'com.android.support:appcompat-v7:23.1.1'
编译' 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:1.2.9@aar'
compile'com.github.siyamed:android-shape-imageview:0.9。+ @ aar'
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
buildToolsVersion23.0.1
useLibrary'org.apache.http.legacy'
defaultConfig {
applicationIdcom.snsepro.mym
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName1.0
multiDexEnabled = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile(' proguard-android.txt'),'progu ard-rules.pro'
}
}
dexOptions {
javaMaxHeapSize4g
}
packagingOptions {
exclude 'META-INF / DEPENDENCIES'
排除'META-INF /通知'
排除'META-INF / LICENSE'
排除'META-INF / LICENSE.txt'
排除'META-INF / NOTICE.txt'
}
}
ext {
supportLibVersion = '23 .1.1'//可以被引用以保持支持库一致的变量
存储库{
maven {url'https://zendesk.artifactoryonline.com/zendesk/repo'}
}
依赖关系{
编译fileTree(dir:'libs',include:['* .jar'])
编译文件('libs / gcm.jar')
编译文件('libs / gcm
编译文件('libs / picasso-2.5.2.jar')
编译文件('libs / jsoup-1.7.3.jar')
编译文件('libs / gson-2.2.4.jar')
编译文件('lib s / volley.jar')
编译文件('libs / cometchat-sdk.jar')
编译'com.android.support:appcompat-v7:23.1.1'
编译' 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:1.2.9@aar'
compile'com.github.siyamed:android-shape-imageview:0.9。+ @ aar'
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:car dview-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'
}
解决方案
什么库是你的编译文件('libs / volley.jar')如果它是一样的,你肯定会得到这个错误。尝试在这种情况下删除任何一个。
My Project was working fine, until I added the volley library. Then, it started giving me an error like this:
What should I do to fix this error?
My App gradle is below
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:1.2.9@aar'
compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
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'
}
}
And here is volley library added 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:1.2.9@aar'
compile 'com.github.siyamed:android-shape-imageview:0.9.+@aar'
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'
}
解决方案
What library is your compile files('libs/volley.jar') If it is the same one , you will definitely get this error. Try removing either one in that case.
这篇关于Android Studio Gradle错误“Multiple dex files define ...”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!