[英]my android project dependence the httpclient and httpMime can't build
[英]Android httpcore, httpmime and httpclient-android libraries import givs an error
在我的Android中,我要將文件上傳到后端服務器,並考慮使用MultipartEntity使用HTTP發布請求來執行此操作。 在這種情況下,我首先添加了httpcore和httpmime庫,這給了我一個錯誤。 所以經過一番谷歌搜索后,我發現httpclient-android也必須導入。 所以最后我的build.gradle文件如下所示。
android {
compileSdkVersion 'Google Inc.:Google APIs:21'
buildToolsVersion '23.0.2'
defaultConfig {
applicationId "com.m.l"
minSdkVersion 14
targetSdkVersion 19
versionCode 69
versionName '2.0.15'
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
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'
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}
dependencies {
compile project(':holoColorPickermaster')
compile project(':qRCodeReaderViewlib')
compile project(':volley')
compile project(':library')
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:multidex:'
compile 'org.apache.httpcomponents:httpcore:4.4.4'
compile('org.apache.httpcomponents:httpmime:4.3.6') {
exclude module: 'httpclient'
}
compile 'org.apache.httpcomponents:httpclient-android:4.3.5'
}
但是現在當我運行該應用程序時,它會提示我另一個錯誤。我的錯誤日志如下所示,
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/http/concurrent/BasicFuture.class
我在網絡中查找此錯誤,然后嘗試修復它。 但沒有適當的解決方案。 發現這是由於文件重復引起的。 我怎樣才能解決這個問題。 謝謝並恭祝安康。
如果您有一些不想被編譯的源代碼,則必須為源代碼聲明一個過濾器,而不是為Jar中放置的類文件聲明一個過濾器。 就像是:
sourceSets {
main {
java {
include 'com/ourcompany/somepackage/activityadapter/**'
include 'com/ourcompany/someotherpackage/**'
exclude 'com/ourcompany/someotherpackage/polling/**'
}
}
}
如果您不想編譯這些軟件包,那么此解決方案是有效的,但是如果您要編譯它們並從JAR中排除,則可以使用
jar {
exclude('mi/package/excluded/**')
exclude('mi/package/excluded2/**')
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.