【发布时间】:2018-04-09 21:38:09
【问题描述】:
我已将 Android Studio 更新到版本 3,但现在似乎无法编译我之前编译的项目而没有错误。
错误信息如下
Error:Error: commons-logging 定义的类与 现在由 Android 提供的类。解决方案包括寻找更新的 没有相同问题的版本或替代库 (例如,对于 httpclient 使用 HttpUrlConnection 或 okhttp 代替), 或使用 jarjar 之类的东西重新打包库。 [重复平台类]
依赖关系是
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 插件还是我遗漏了什么?与以前的版本编译完全一样的项目没问题。
【问题讨论】:
-
"那为什么它不编译?" -- 你的问题是
commons-logging,基于错误。也许您应该使用这些com.google依赖项的更新版本。 -
@CommonsWare我没有找到任何更新的库这些版本是 2017 年 10 月的最新版本
-
libs 文件夹中是否有相同的 jar?
-
@GabrieleMariotti 绝对不是。我在 libs 文件夹中没有任何罐子。这些库仅在 build.gradle 的依赖项部分中指定(否则以前的 Android 工作室也会拒绝构建)。出于这个原因,我无法弄清楚为什么 Android Studio 更新后无法编译。
标签: android android-studio android-gradle-plugin android-studio-3.0 android-gradle-3.0