无法找到可选库:org.apache.http.legacy
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了无法找到可选库:org.apache.http.legacy相关的知识,希望对你有一定的参考价值。
从stackoverflow尝试了一切。我在下面列出了我试图纠正这个错误的所有内容:(我知道有很多答案。它仍然不适合我)
- 检查是否存在.json文件(检查)
- 将“useLibrary'org.apache.http.legacy'”添加到app module gradle文件中(check)
- 将.jar文件从sdk位置添加到libs(检查)
- 重新安装API 23(检查)
- 右键单击libs文件夹中的jar并添加到库(检查)
- 更改位置以避免256个字符。 (校验)
- 将“compile fileTree(dir:'libs',include:['* .jar'])”添加到gradle文件依赖项(默认情况下存在)(check)
这几乎是所有答案中的一切。有人可以提供解决方案吗?我已经在这10个小时了;重新安装和更改脚本。
我的Gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.example.name"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.0.0-alpha1'
}
答案
对我来说,我使用它,它的工作原理:
android {
useLibrary 'org.apache.http.legacy' // put it in here
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.name"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
另一答案
首先确保使用此gradle插件或更高版本:
classpath 'com.android.tools.build:gradle:1.3.1'
然后检查Android/Sdk/platforms/android-23/optional
文件夹是否包含optional.json
文件。
一个好主意是使用最新版本:
classpath 'com.android.tools.build:gradle:2.2.0'
没有这个版本你将无法处理useLibrary 'org.apache.http.legacy'
它与您的问题无关,但也检查您的依赖项和用于编译的api。
android {
compileSdkVersion 24
//....
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:24.2.1'
}
另一答案
我能够解决警告信息
Unable to find optional library: org.apache.http.legacy
通过升级我的Android工作室。这是1.3.2。现在是2.2。
以上是关于无法找到可选库:org.apache.http.legacy的主要内容,如果未能解决你的问题,请参考以下文章
Spring Boot后控制器无法找到数据库ID,返回可选错误[关闭]