commons-validator and error “commons-logging defin

2020-05-09 08:40发布

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?

1条回答
爱情/是我丢掉的垃圾
2楼-- · 2020-05-09 09:23

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'
    }
}
查看更多
登录 后发表回答