我遇到了一个严重的问题。在我的项目中,我有一个库(.aar)文件,它包含一个appcompat-v7兼容性库。现在,在我的项目中,在gradle.build (app)文件的依赖部分下面还有另一个appcompat-v7。
问题是,当我运行应用程序时,它抛出一个异常,即
UNEXPECTED TOP-LEVEL EXCEPTION:com.android.dex.DexException: Multiple dex files define Landroid/support/v7/appcompat/R$anim;这是我的应用程序gradle.build (app)文件的相关部分(我想是的)
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:22.2.1'
compile(name: 'conversityChat-debug', ext: 'aar') {
exclude group: 'com.android.support', module: 'support-v7'
}
}这是我的库gradle.build(app)文件的相关部分(我想是的)
dependencies {
compile project(':androidwebsocketsmaster')
compile 'com.android.support:appcompat-v7:22.2.1'
compile files('libs/acra-4.5.0.jar')
compile files('libs/universal-image-loader-1.9.4.jar')
}我用的是安卓工作室。我知道以前有人问过这个问题,我已经尝试过所有可能的解决方案。可悲的是他们都没帮上忙..。请帮帮我
发布于 2015-10-14 11:43:49
将以下代码添加到您的分级中:
defaultConfig {
...
minSdkVersion 14
targetSdkVersion 21
...
// Enabling multidex support.
multiDexEnabled true
}添加下面的依赖项,并添加HttpCore和HttpClient。
dependencies {
compile 'com.android.support:multidex:1.0.0'
}有关更多信息,请查看以下链接:
https://developer.android.com/tools/building/multidex.html
谢谢!
发布于 2015-10-14 10:49:23
删除
compile 'com.android.support:appcompat-v7:22.2.1'从外部级别的build.gradle文件(顶部的文件)中,您只需要在项目级别的build.gradle文件中使用它。
https://stackoverflow.com/questions/33123181
复制相似问题