我必须重新安装系统,今天当我尝试与 gradle 同步时,我在 Android Studio 中收到此错误:
Warning: Unable to find optional library: org.apache.http.legacy
我的项目等级是:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
allprojects {
repositories {
mavenCentral()
}
}
和我的模块 gradle:
apply plugin: 'android'
android {
useLibrary 'org.apache.http.legacy'
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
}
buildTypes {
release {
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
}
来自谷歌文档 http://developer.android.com/about/versions/marshmallow/android-6.0-changes.html#behavior-apache-http-client:
要继续使用 Apache HTTP API,您必须首先声明
在 build.gradle 文件中遵循编译时依赖项:
android {
useLibrary 'org.apache.http.legacy'
}
我尝试了中提到的建议这个线程 https://stackoverflow.com/questions/31653002/how-to-use-the-legacy-apache-http-client-on-android-m但它们不起作用。 android studio 1.5 和 2 预览版的结果相同。
我怎样才能解决这个问题?
Edit:到目前为止我尝试过的事情:
将 gradle 类路径版本更改为 1.3.0、1.3.1、1.5.0。
改变compileSdkVersion
and targetSdkVersion
到 22。还有 23.0.1、23.0.0、22.0.1 的 buildToolsVersion。
顶级 build.gradle - /build.gradle
buildscript {
...
dependencies {
classpath 'com.android.tools.build:gradle:1.3.1'
}
}
模块特定的 build.gradle - /app/build.gradle
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
useLibrary 'org.apache.http.legacy'
...
}
添加 org.apache.http.legacy.jar 位于Android/Sdk/平台/android-23/可选文件夹到app/libs目录并同步您的项目
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)