我正在尝试将 IntelliJ 项目转换为 Android Studio 的 Gradle 系统,但我遇到了 Apache HttpClient 错误?我错过了什么吗,我得到的错误如下:
Error:(10, 30) error: package org.apache.http.client does not exist
Error:(11, 30) error: package org.apache.http.client does not exist
Error:(12, 37) error: package org.apache.http.client.entity does not exist
Error:(13, 38) error: package org.apache.http.client.methods does not exist
Error:(14, 38) error: package org.apache.http.client.methods does not exist
Error:(15, 38) error: package org.apache.http.client.methods does not exist
Error:(16, 35) error: package org.apache.http.impl.client does not exist
Error:(134, 33) error: cannot find symbol class HttpUriRequest
Error:(164, 39) error: cannot find symbol class HttpUriRequest
Error:(106, 17) error: cannot find symbol class HttpGet
Error:(106, 39) error: cannot find symbol class HttpGet
Error:(117, 17) error: cannot find symbol class HttpPost
Error:(117, 40) error: cannot find symbol class HttpPost
Error:(125, 43) error: cannot find symbol class UrlEncodedFormEntity
Error:(135, 9) error: cannot find symbol class HttpClient
Error:(135, 33) error: cannot find symbol class DefaultHttpClient
Error:(155, 18) error: cannot find symbol class ClientProtocolException
Error:(165, 9) error: cannot find symbol class HttpClient
Error:(165, 33) error: cannot find symbol class DefaultHttpClient
Error:(185, 18) error: cannot find symbol class ClientProtocolException
我的 build.gradle 文件有以下依赖:
dependencies {
compile 'com.google.android.gms:play-services:+'
compile 'org.apache.httpcomponents:httpclient:4.2.6'
compile 'org.apache.httpcomponents:httpmime:4.2.6'
compile files('libs/core.jar')
}
似乎很多人都遇到了类似的问题,但 SO 或 Google 都没有解决方案,所以我希望这个问题能对 future 的搜索者有所帮助。
最佳答案
如果您使用 target sdk as 23 在您的 build.gradle 中添加以下代码
android{
compileSdkVersion 23
buildToolsVersion '23.0.1'
useLibrary 'org.apache.http.legacy'
}
并将您的构建脚本更改为
classpath 'com.android.tools.build:gradle:1.3.0'
更多信息请关注 link
关于Android Gradle Apache HttpClient 不存在?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31433687/