【发布时间】:2016-03-02 09:18:02
【问题描述】:
我在运行应用程序时遇到这样的错误。我在 MainActivity 中使用 HttpClient、HttpEntity、HttpResponse 和 HttpPost..所以我对 gradle 文件进行了一些修改。之后我收到这样的错误。
Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/http/ConnectionClosedException.class
我还在我的应用程序中包含了 multidex 库和 org.apache.http.legacy.jar。但是我也遇到了同样的错误。
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.test1"
minSdkVersion 15
targetSdkVersion 23
multiDexEnabled true
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'org.jbundle.util.osgi.wrapped:org.jbundle.util.osgi.wrapped.org.apache.http.client:4.1.2'
compile 'org.apache.httpcomponents:httpcore:4.4.1'
compile 'org.apache.httpcomponents:httpclient:4.5'
compile 'com.android.support:appcompat-v7:23.2.0'
compile 'com.android.support:multidex:1.0.1'
compile files('libs/org.apache.http.legacy.jar')
compile 'org.apache.httpcomponents:httpmime:4.5.1'
}
我知道这个问题已经被问过很多次了,但是没有一个解决方案对我有用.. 谁能帮我解决这个问题。
【问题讨论】:
-
您正在添加此类 org/apache/http/ConnectionClosedException 两次。检查你的依赖关系。
-
我检查了..我只添加了一次..甚至我在依赖项中评论了
compile files('libs/org.apache.http.legacy.jar')这一行,因为我已经将 jar 文件复制到了 libs 文件夹中..但是我也遇到了同样的错误. -
@GabrieleMariotti 可能是什么问题..?
标签: android-studio android-gradle-plugin android-support-library android-multidex