commons-logging定义与Android Studio更新后与Android现在提供的类冲突的类 [英] commons-logging defines classes that conflict with classes now provided by Android after Android Studio Update

查看:322
本文介绍了commons-logging定义与Android Studio更新后与Android现在提供的类冲突的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将Android Studio更新到版本3,现在似乎无法编译以前编译的项目而没有错误.

I have updated Android Studio to version 3 and now seems unable to compile my project previously compiled without errors.

错误消息如下

错误:错误:commons-logging定义了与以下类冲突的类 现在由Android提供的类.解决方案包括寻找更新的 没有相同问题的版本或替代库 (例如,对于httpclient,请使用HttpUrlConnection或okhttp代替), 或使用jarjar之类的东西重新打包库. [DuplicatePlatformClasses]

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]

依赖项是

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:27.0.0'
    compile 'com.android.support:design:27.0.0'
    compile 'com.google.api-client:google-api-client-android:1.23.0' exclude module: 'httpclient'
    compile 'com.google.http-client:google-http-client-gson:1.23.0' exclude module: 'httpclient'
    compile 'com.google.firebase:firebase-core:11.4.2'
}

并且错误似乎是由

compile 'com.google.api-client:google-api-client-android:1.23.0' exclude module: 'httpclient'
compile 'com.google.http-client:google-http-client-gson:1.23.0' exclude module: 'httpclient'

我已经使用了exclude module: 'httpclient' 那为什么它不编译呢? 这是Android Studio 3和/或包含的com.android.tools.build:gradle:3.0.0插件的错误,还是我丢失了某些东西?使用以前的版本,完全可以编译完全相同的项目.

I already use exclude module: 'httpclient' So why It doesn't compile? Is this a bug of Android Studio 3 and\or included com.android.tools.build:gradle:3.0.0 plugin or I'm missing something? With the previous version no problem to compile exactly the same project.

推荐答案

添加到位于应用模块中的build.gradle

Add to build.gradle located in app module

configurations {
    all {
        exclude module: 'httpclient'
    }
}

这篇关于commons-logging定义与Android Studio更新后与Android现在提供的类冲突的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆