問題描述
我已將 Android Studio 更新到版本 3,現(xiàn)在似乎無法編譯我之前編譯的項目而沒有錯誤.
I have updated Android Studio to version 3 and now seems unable to compile my project previously compiled without errors.
錯誤信息如下
Error:Error: commons-logging 定義的類與現(xiàn)在由 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'
我已經(jīng)在使用 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 現(xiàn)在提供的類沖突的類的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!