Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: android defines classes that conflict with classes now provided by Android , when we start to generate release build

I had several libraries conflict issues. That i resolved by adding

configurations {

all {
    exclude module: 'httpclient'
    exclude module: 'commons-logging'
    exclude group: 'org.json', module: 'json'
    exclude group: 'org.apache.httpcomponents'
    exclude module: 'xmlParserAPIs'
    exclude module: 'xpp3'
    exclude module: 'opengl-api'
}

}

But still following error present. And i am unable to build signed apk. I have tried project clean/rebuild option.

Error: android defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for httpclient use HttpUrlConnection or okhttp instead), or repackaging the library using something like jarjar. [DuplicatePlatformClasses]

Thanks in advance for your help.

like image 717
Rana.S Avatar asked Jan 24 '26 13:01

Rana.S


1 Answers

Problem

How to see which dependency is creating conflicts. It is same like shooting in dark.

Solution

Some AS plugin that will show you which projects dependency hierarchy. You can find where issue presents exactly and solve that.

Gradle View is an Android Studio plugin that you can install and show dependency hierarchy.

enter image description here

Methods Count is another plugin, it also shows dependency tree.

enter image description here

like image 123
Khemraj Sharma Avatar answered Jan 27 '26 01:01

Khemraj Sharma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!