2015年6月2日 星期二

【Android】Android Studio 之中使用 httpcore 與 httpmime


解決2個問題

1. WARNING: Dependency org.apache.httpcomponents:httpclient:4.3.5 is ignored for debug as it may be conflicting with the internal version provided by Android. In case of problem, please repackage it with jarjar to change the class packages
 
2. Duplicate files copied in APK META-INF/NOTICE 





可在 build.gradle 之中, 加入

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'com.android.support:support-v4:22.1.1'

    compile files('libs/commons-lang-2.6.jar')     // 記得在 Libs 之中加入相對映的 jar 檔
    compile files('libs/httpcore-4.4.jar')
    compile files('libs/httpmime-4.3.5.jar')
}


android {
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'

    }
}

沒有留言:

張貼留言