代码之家  ›  专栏  ›  技术社区  ›  tm1701

android:使用httpcomponents升级gradle 4.4-错误:程序类型已存在:org.apache.http.auth.challengestate

  •  1
  • tm1701  · 技术社区  · 6 年前

    当升级到Gradle4.4My应用程序时,我在构建过程中会遇到以下错误。如何升级?

    我知道(并校对过)这与这些图书馆有关:

    implementation 'org.apache.httpcomponents:httpclient-android:4.3.5'
    implementation('org.apache.httpcomponents:httpmime:4.3.5') {
        exclude module: 'org.apache.httpcomponents:httpclient'
    }
    

    程序类型已存在:org.apache.http.auth.challengestate message kind=错误,text=程序类型已存在: org.apache.http.auth.challengestate,sources=[未知源文件], 刀具名称=可选(D8)

    我的其他应用程序使用其他方式通过HTTP进行集成。这个应用程序的成本/收益较低,所以我希望保持httpclient集成。

    其他错误包括:

    原因:com.android.tools.r8.compilationfailedexception: 编译未能在完成 COM.Android .Ro.R8. UTIL.ExtExtuutUL.FuffCuliTracle处理程序(ExtrutuutULS.java:76) 在 COM.Android .Ro.R8. UTIL.ExabutUTIL.WUD8COMPILITCHAND(异常Extrus.java:45) 在COM.Android .Roo.R8.D8.运行(D8. Java:67)AT COM.Android .Builder。德兴。D8DestCraceVielder。MeGeExtRebug(D8DestCuileExavel.java:107)

    我的依赖关系是:

    dependencies {
        implementation 'com.android.support:design:27.1.1'
        implementation 'com.android.support:appcompat-v7:27.1.1'
        implementation 'com.android.support:cardview-v7:27.1.1'
        implementation 'com.android.support:support-v4:27.1.1'
        implementation 'com.android.support:recyclerview-v7:27.1.1'
        implementation 'com.android.support:gridlayout-v7:27.1.1'
        implementation group: 'commons-io', name: 'commons-io', version: '2.5'
        implementation 'org.apache.httpcomponents:httpclient-android:4.3.5'
        implementation('org.apache.httpcomponents:httpmime:4.3.5') {
            exclude module: 'org.apache.httpcomponents:httpclient'
        }
        implementation files('libs/commons-lang3-3.1.jar')
        implementation files('libs/GraphView-3.1.2.jar')
        implementation files('libs/httpcore-4.0.1.jar')
        implementation files('libs/jackson-core-2.2.3.jar')
        implementation files('libs/nineoldandroids-2.4.0.jar')
    

    在build.gradle中,我(当然)添加了:

    android {
        compileSdkVersion 27
        buildToolsVersion '27.0.3'
        useLibrary  'org.apache.http.legacy' <======
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   tm1701    6 年前

    不是最简单但更好的解决方案是将HTTP调用迁移到OKHTTP。现在不做时,需要在不久的将来迁移。

    我迁移到OKHTTP的应用程序工作正常。OKHTTP很好用。