Android Studio:错误:无法找到可选库:org.apache.http.legacy

时间:2016-10-21 22:53:30

标签: android android-studio gradle android-gradle build.gradle

我知道这个问题在很多时候都有。我尝试了所有的解决方案。我有一个app的源代码。我想构建它,但我收到此错误:错误:无法找到可选库:org.apache.http.legacy

以下是 build.gradle(模块应用)

的一部分
apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion '21.1.2'

    dexOptions {
        javaMaxHeapSize "4g"
    }

    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.sensiblewallet"
        minSdkVersion 16
        targetSdkVersion 21
        multiDexEnabled true
    }

    signingConfigs {
        release {
            storeFile file("android.keystore")
            storePassword "123456"
            keyAlias "sensiblewallet"
            keyPassword "123456"
        }
    }

    buildTypes {
        release {
            //minifyEnabled false
            //proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
            //signingConfig signingConfigs.release
            //multiDexEnabled true
        }
    }
}

这是 build.gradle(Project)

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.1'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

我尝试了一切......出了什么问题?请帮助我,非常感谢!

1 个答案:

答案 0 :(得分:0)

您必须使用API​​ 23 +:

android {
     compileSdkVersion 23
     buildToolsVersion "23.0.0"

     useLibrary 'org.apache.http.legacy'

}