尝试了 stackoverflow 中的所有内容。我在下面列出了我尝试纠正此错误的所有内容:(我知道对此有很多答案。它仍然不适合我)
- 检查 .json 文件是否存在(检查)
- 将“useLibrary 'org.apache.http.legacy'”添加到应用模块 gradle 文件(选中)
- 将 .jar 文件从 sdk 位置添加到库(选中)
- 重新安装 API 23(选中)
- 右键单击 libs 文件夹中的 jar 并添加到库(选中)
- 更改位置以避免 256 个字符。 (检查)
- 将“compile fileTree(dir: 'libs', include: ['*.jar'])”添加到 gradle 文件依赖项(默认存在)(选中)
这几乎是所有答案的全部内容。有人可以提供解决方案吗?我已经在这上面花了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'
}
}
}
关于android - 无法找到可选库 : org. apache.http.legacy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39760620/