Skip to content Skip to sidebar Skip to footer

Adding Httpcore And Httpmime Libraries To Android Project Gives An Error In Running The App

In my Android app I'm using httpcore and httpmime libraries. My build.gradle files dependancy section contains below part, compile 'org.apache.httpcomponents:httpcore:4.4.4' compil

Solution 1:

add this in your build.gradle file

android {
    packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
    }
}

Solution 2:

Better to use this one, it will include only one license file, some licenses (most of open source) do not allow to exclude license from final code:

    packagingOptions {
    pickFirst 'META-INF/DEPENDENCIES.txt'
    pickFirst 'META-INF/LICENSE.txt'
    pickFirst 'META-INF/NOTICE.txt'
    pickFirst 'META-INF/NOTICE'
    pickFirst 'META-INF/LICENSE'
    pickFirst 'META-INF/DEPENDENCIES'
    pickFirst 'META-INF/notice.txt'
    pickFirst 'META-INF/license.txt'
    pickFirst 'META-INF/dependencies.txt'
    pickFirst 'META-INF/LGPL2.1'
}

It is not the best option since if you will have different license files with the same name you will loose one, but much better than exclude everything.

Post a Comment for "Adding Httpcore And Httpmime Libraries To Android Project Gives An Error In Running The App"