2016-10-19 122 views
0

已解决此问题。 我删除了所有* .jar文件并添加下面的代码。Android Studio .apk build ZipException错误

这是我的编辑的gradle代码

compile group: 'org.apache.httpcomponents', name: 'httpclient-android', version: '4.3.5' 

compile (group: 'org.apache.httpcomponents', name: 'httpmime', version: '4.3.6') { 

    exclude module: 'org.apache.httpcomponents:httpclient' 

} 




所有。

我有一个错误,但我不知道如何解决它。 我需要你的帮助。

我不太习惯StackOverflow网站。

因为我希望你能理解我在帖子中的错误。

这是错误:

Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.

com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/http/MessageConstraintException.class

和我的build.gradle代码:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "24.0.0" 
defaultConfig { 
    applicationId "com.example.daehwankim" 
    minSdkVersion 19 
    targetSdkVersion 23 
    versionCode 1 
    versionName "1.0" 
    multiDexEnabled true 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 
packagingOptions { 
    exclude 'META-INF/DEPENDENCIES' 
    exclude 'META-INF/NOTICE' 
    exclude 'META-INF/LICENSE' 
    exclude 'META-INF/LICENSE.txt' 
    exclude 'META-INF/NOTICE.txt' 
} 

useLibrary 'org.apache.http.legacy' 

} 

dependencies { 

compile fileTree(include: ['*.jar'], dir: 'libs') 
testCompile 'junit:junit:4.12' 
compile files('libs/httpclient-4.3.1.jar') 
compile files('libs/httpclient-android-4.3.5.jar') 
compile files('libs/httpcore-4.3.jar') 
compile files('libs/httpmime-4.3.1.jar') 
compile 'com.android.support:appcompat-v7:24.2.0' 
compile 'com.google.android.gms:play-services:9.4.0' 
compile 'com.github.bumptech.glide:glide:3.7.0' 
compile 'com.google.firebase:firebase-messaging:9.4.0' 
compile 'com.squareup.okhttp3:okhttp:3.2.0' 
compile 'com.github.chrisbanes:PhotoView:1.3.0' 
compile 'com.android.support:multidex:1.0.0' 
compile 'com.google.android.gms:play-services-ads:9.4.0' 
compile 'com.google.android.gms:play-services-auth:9.4.0' 
compile 'com.google.android.gms:play-services-gcm:9.4.0' 
} 

apply plugin: 'com.google.gms.google-services' 
+0

您有多个'com.google.android.gms:' –

+0

@IntelliJAmiya如何编辑我的代码..? –

回答

0

你需要这两种?

编译文件( '库/ HttpClient的-4.3.1.jar') 编译文件( '库/ HttpClient的,Android的4.3.5.jar')

我觉得都有MessageConstraintException类中,但不确定。尝试删除第一个库(如果第二个库已足够)

+0

谢谢你的评论, –

+0

我删除firest库。但同样的错误发生...... :-( –

+0

这个想法是看看3个http jar里面,看看它们中是否包含这个类,试着删除它们,也是一个很好的“干净的项目”,可以帮到我 –