Getting NoSuchFieldError INSTANCE org/apache/http/message/BasicHeaderValueParser

后端 未结 6 573
無奈伤痛
無奈伤痛 2020-11-27 16:54

I\'m working on an app on Android. I\'m using httpcore 4.3.3. I get this when I try to use ContentType.parse(string)

java.lang.NoSuchFieldError:         


        
相关标签:
6条回答
  • 2020-11-27 17:06

    Just add httpmime_4.3.6.jar of version 4.3.6 file in lib folder and add

    implementation files('lib/httpmime-4.3.6.jar') in gradle(app level)

    0 讨论(0)
  • 2020-11-27 17:08

    Simple solution is to use:

    https://code.google.com/p/httpclientandroidlib/

    It's the Appache HttpClient port for android wrap in a different package name so that will not interfere with the existing version in Android. Import the jar in the Android project and instead of "org.apache.http" use "ch.boye.httpclientandroidlib."

    0 讨论(0)
  • 2020-11-27 17:11

    Looks like you use incompatible jar's for httpmime and httpclient-android. Try to use version 4.3.6 of httpmime

    0 讨论(0)
  • 2020-11-27 17:24

    Unfortunately stock versions of HttpCore cannot be used in Android. Please use Apache HttpClient Android Port which also includes requisite HttpCore classes

    compile('org.apache.httpcomponents:httpmime:4.3.6') {
        exclude module: 'httpclient'
    }
    compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
    
    0 讨论(0)
  • 2020-11-27 17:25

    Download latest Apache Httpclient Jar file and refract path name. That works for me.

    0 讨论(0)
  • 2020-11-27 17:27

    Note : If you are using both apache httpmime and retrofit simultaneously Use apache httpmime older version.

    (eg : in my case i used this to upload a image on server and also to get the content lenghth/image size)

    This his an older version (not so old) or prev version, You should implement same old version for both.

    implementation 'com.squareup.retrofit2:retrofit:2.0.2' implementation 'org.apache.httpcomponents:httpmime:4.3.6'

    This his an new version of retrofit, You should use old version apache httpmime.

    implementation 'com.squareup.retrofit2:retrofit:2.3.0' implementation 'org.apache.httpcomponents:httpmime:4.3.6'

    Thank You so much, If u loved my solution plz voteup for me.

    0 讨论(0)
提交回复
热议问题