0

After recent Android Studio update, I can build and run an app in the debug mode, but am no longer able to build the release version due to the following error:

Error:Error: commons-logging 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]

I have read this post and this post. Both answers suggest "exclude module: 'httpclient'". It does not solve the problem of my case. I am fairly sure it is related to the following:

compile 'commons-validator:commons-validator:1.6'

Could anyone offer a tip on the remedy?

Hong
  • 17,643
  • 21
  • 81
  • 142

1 Answers1

2

The problem is with commons-logging. So it must be excluded. Add the following code in app/build.gradle. It should work.

configurations {
    all {
        exclude module: 'httpclient'
        exclude module: 'commons-logging'
    }
}
srs
  • 2,521
  • 16
  • 16
  • Then causing the error that httpclient package not found – Asif Mushtaq Nov 09 '17 at 13:18
  • That means your project is using httpclient module. Try excluding only common-logging module – srs Nov 09 '17 at 14:01
  • Actually I want to know explanation about the error. Mean what does it mean conflicting the old and new way of http? – Asif Mushtaq Nov 09 '17 at 16:11
  • Thanks for the answer. It appears to be working. I will do more testing with the apk generated in this way, and report back if there are any issues. – Hong Nov 09 '17 at 18:39