【问题标题】:Compatibility with HttpClient and SDK v23与 HttpClient 和 SDK v23 的兼容性
【发布时间】:2016-04-21 07:10:44
【问题描述】:

首先我为我糟糕的英语道歉。我的问题是我无法协调在不同版本的 Android 上运行的两个代码,因为它们是:

    import org.apache.http.client.HttpClient; (This work with 22)
    import com.github.paolorotolo.appintro.AppIntro;(This work with 23)

如果我将我的项目设置为版本 22,它只能工作 HTTPClient ,但更改为 23 无法识别它,但它可以工作 AppIntro 。 附件“build.gradle”和每种情况下的错误输出。我必须同时使用它们,因为它们非常适合我的项目,具有讽刺意味的是

    apply plugin: 'com.android.application'

    android {
compileSdkVersion 22
buildToolsVersion "22.0.1"

defaultConfig {
    applicationId "com.example.victo.cqbo_definitive"
    minSdkVersion 15
    targetSdkVersion 22
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile 'com.github.paolorotolo:appintro:3.4.0'
}


Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
Error:(24) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
Error:Execution failed for task ':app:processDebugResources'.
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\victo\AppData\Local\Android\sdk\build-tools\22.0.1\aapt.exe'' finished with non-zero exit value 1

非常感谢你,我希望能帮助我解决问题

【问题讨论】:

    标签: java android apache android-studio sdk


    【解决方案1】:

    从 Android L 开始,Google 不再维护 Apache HTTP 库。他们专注于 URLConnection Java API。

    幸运的是,通过将useLibrary 'org.apache.http.legacy' 放在 gradle 脚本上,始终可以在 API23+ 上使用 Apache HTTP 库:

    android {
        compileSdkVersion 23
        buildToolsVersion "23.0.0"
        useLibrary 'org.apache.http.legacy'
        ...
    }
    

    Android 6.0 Changes - Apache HTTP Client Removal

    【讨论】:

    • 当我尝试这样做时,构建失败并出现以下错误:错误:无法找到可选库:org.apache.http.legacy
    • 您的 SDK 可能存在问题。请务必在 Android SDK Manager 中更新您的构建工具和 Android 工具。来自this
    猜你喜欢
    • 2019-05-15
    • 1970-01-01
    • 2018-04-19
    • 2016-04-20
    • 1970-01-01
    • 1970-01-01
    • 2021-11-22
    • 2012-12-15
    • 1970-01-01
    相关资源
    最近更新 更多