在Android Studio 3.4.1中
app/build.gradle:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'org.apache.httpcomponents:httpclient:4.5.9'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
但是在这一行中我得到了错误;
implementation 'org.apache.httpcomponents:httpclient:4.5.9'
错误:
httpclient 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. more... (Ctrl+F1)
答案 0 :(得分:1)
在此变更日志中查找Android API。
您应该用HttpURLConnection替换Apache HTTP函数,或者在build.gradle
中使用此功能片段,以继续使用现在不建议使用的Apache库。
android {
useLibrary 'org.apache.http.legacy'
}