2015-10-14 76 views
1

我遇到了一个令人讨厌的问题。在我的项目中,我有一个库(.aar)文件,其中包含一个appcompat-v7兼容库。现在在我的项目,我也有下gradle.build(应用程序)文件的依赖关系部的另一程序兼容性-V7 ..Android中的Appcompat-v7冲突

问题是,当我运行的应用程序,它抛出一个异常说

UNEXPECTED TOP-LEVEL EXCEPTION:com.android.dex.DexException: Multiple dex files define Landroid/support/v7/appcompat/R$anim; 

这里是我的应用程序gradle.build(应用程序)文件的相关部分(我是这么认为的)

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(应用程序)文件的相关部分(我是这么认为的)

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') 
} 

我正在使用android工作室..我知道这个问题已被问及之前,我已经尝试过所有可能的解决方案。可悲的是,他们没有帮助......请帮我

回答

1

添加下面的代码到你的gradle产出:

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

谢谢..!

0

从外部级的build.gradle文件(最上面的一个)移除

compile 'com.android.support:appcompat-v7:22.2.1' 

你只需要在您的项目级的build.gradle文件。

+0

我没有在我的项目级别的build.gradle文件..第一个是应用程序build.gradle(应用程序)文件,最下面是自定义库build.gradle文件...你可以更具体请吗? –

+0

你有两个build.gradle文件,一个在你的app目录中,另一个在你项目的根目录下。您希望将appcompat依赖项放在应用程序中,而不是根目录。错误是说你指定了两次。 – vguzzi