Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate class org.apache.http.HttpHeaders found in modules

After updating my Android Studio to 3.5 version. I'm getting error this error:

Duplicate class org.apache.http.Consts found in modules
        httpclient-android-4.3.5.1.jar
        (org.apache.httpcomponents:httpclient-android:4.3.5.1) and
        httpcore-4.3.2.jar (org.apache.httpcomponents:httpcore:4.3.2)
        Duplicate class org.apache.http.ContentTooLongException found in
modules httpclient-android-4.3.5.1.jar
        (org.apache.httpcomponents:httpclient-android:4.3.5.1) and
        httpcore-4.3.2.jar (org.apache.httpcomponents:httpcore:4.3.2)
        Duplicate class org.apache.http.HttpConnectionFactory found in modules
        httpclient-android-4.3.5.1.jar
        (org.apache.httpcomponents:httpclient-android:4.3.5.1) and
        httpcore-4.3.2.jar (org.apache.httpcomponents:httpcore:4.3.2)
        Duplicate class org.apache.http.HttpHeaders found in modules
        httpclient-android-4.3.5.1.jar
        (org.apache.httpcomponents:httpclient-android:4.3.5.1) and
        httpcore-4.3.2.jar (org.apache.httpcomponents:httpcore:4.3.2)
        Duplicate class org.apache.http.MessageConstraintException found in
modules httpclient-android-4.3.5.1.jar
        (org.apache.httpcomponents:httpclient-android:4.3.5.1) and
        httpcore-4.3.2.jar (org.apache.httpcomponents:httpcore:4.3.2)
        Duplicate class org.apache.http.TruncatedChunkException found in
modules httpclient-android-4.3.5.1.jar
        (org.apache.httpcomponents:httpclient-android:4.3.5.1) and
        httpcore-4.3.2.jar (org.apache.httpcomponents:httpcore:4.3.2)
        Duplicate class org.apache.http.annotation.GuardedBy found in modules
        httpclient-android-4.3.5.1.jar
        (org.apache.httpcomponents:httpclient-android:4.3.5.1) and
        httpcore-4.3.2.jar (org.apache.httpcomponents:httpcore:4.3.2)
        Duplicate class org.apache.http.annotation.Immutable found in modules
        httpclient-android-4.3.5.1.jar
        (org.apache.httpcomponents:httpclient-android:4.3.5.1) and
        httpcore-4.3.2.jar (org.apache.httpcomponents:httpcore:4.3.2)
like image 443
Mohammed Ali Avatar asked Jul 24 '26 20:07

Mohammed Ali


1 Answers

Resolved by excluding the duplicates from the implemented libraries in your gradle file:

implementation ('org.apache.httpcomponents:httpclient-android:4.3.5.1') {
    exclude group: 'org.apache.http'
}

implementation ('org.apache.httpcomponents:httpcore:4.3.2') {
    exclude group: 'org.apache.http'
}

If you require more help post your gradle file in its entirety.

like image 119
JakeB Avatar answered Jul 26 '26 09:07

JakeB