commons-logging 定义了与 Android Studio 更新后 Android 现在提供的类冲突的类

commons-logging defines classes that conflict with classes now provided by Android after Android Studio Update(commons-logging 定义了与 Android Studio 更新后 Android 现在提供的类冲突的类)
本文介绍了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.

错误信息如下

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

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 andor 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 现在提供的类冲突的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Android release APK crash with java.lang.AssertionError: impossible in java.lang.Enum(Android 发布 APK 因 java.lang.AssertionError 崩溃:在 java.lang.Enum 中不可能)
Finished with Non Zero Exit Value 3(以非零退出值 3 结束)
On gradle:3.0.0 More than one file was found with OS independent path #39;META-INF/ASL2.0#39;(在 gradle:3.0.0 上找到多个文件,其独立于操作系统的路径为“META-INF/ASL2.0)
Android : app loading library at runtime on Lollipop but not IceCreamSandwich(Android:运行时在 Lollipop 上而不是 IceCreamSandwich 上的应用程序加载库)
buildConfigField depending on flavor + buildType(buildConfigField 取决于风味 + buildType)
How do I suppress warnings when compiling an android library with gradle?(使用 gradle 编译 android 库时如何抑制警告?)