Appcompat-v7 conflict in android

北城以北 提交于 2019-12-11 10:12:58

问题


I ran into a nasty problem. In my project I have a library (.aar) file which is including an appcompat-v7 compatibility library. Now in my project I also have another appcompat-v7 under the dependency section of gradle.build (app) file..

The problem is when I run the Application it throws an exception saying

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

Here is my application gradle.build (app) file relevant part (I think so)

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

And here is my library gradle.build(app) file relevant part (I think so)

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

I'm using android studio.. I know this question has been asked before, and I've tried out all possible solutions suggested over there. Sadly, None of them helped... Please help me out


回答1:


Add below code to your gradle :

defaultConfig {
        ...
        minSdkVersion 14
        targetSdkVersion 21
        ...

        // Enabling multidex support.
        multiDexEnabled true
    }

Add below dependency and add HttpCore and HttpClient also.

dependencies {
  compile 'com.android.support:multidex:1.0.0'
}

For more information check below link :

https://developer.android.com/tools/building/multidex.html

Thanks..!!




回答2:


Remove

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

from your outer level build.gradle file (the top one) you only need it in your project level build.gradle file.



来源:https://stackoverflow.com/questions/33123181/appcompat-v7-conflict-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!