【问题标题】:java.util.zip.ZipException: duplicate entry: org/ksoap2/SoapEnvelope.classjava.util.zip.ZipException:重复条目:org/ksoap2/SoapEnvelope.class
【发布时间】:2017-02-23 14:01:42
【问题描述】:

当我尝试将旧的 Eclipse 项目迁移到 Android Studio 2 时遇到问题。我收到以下错误消息:

错误:任务执行失败 ':app:transformClassesWithJarMergingForDebug'.

com.android.build.api.transform.TransformException:java.util.zip.ZipException:重复条目: org/ksoap2/SoapEnvelope.class

我的 build.gradle:

apply plugin: 'com.android.application'
android {
    compileSdkVersion 23
    buildToolsVersion "24.0.2"

    useLibrary 'org.apache.http.legacy'

    defaultConfig {
        applicationId "com.myorg.myapp"
        minSdkVersion 14
        targetSdkVersion 23
        multiDexEnabled true
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile 'com.google.android.gms:play-services:10.2.0'
    compile files('libs/ksoap2-android-assembly-2.5.2-jar-with-dependencies_timeout1.jar')
    compile files('libs/ksoap2-j2se-full-2.1.2.jar')
    compile files('libs/PayPal_MPL.jar')
}

不太明白这些错误是什么意思。任何想法?谢谢。

【问题讨论】:

  • 我认为当你有同一个库的副本时通常会发生错误
  • 按 ctrl+shift+R 并输入 'SoapEnvelope'。

标签: android android-studio android-ksoap2


【解决方案1】:

问题是您正在使用两个包含相同类的 jar 文件。

ksoap2-j2se-full-2.1.2.jar

ksoap2-android-assembly-2.5.2-jar-with-dependencies_timeout1.jar

两个 jar 包含大部分相同的类。更好的方法是使用单个 jar 文件,而不是使用包含类似类的多个 jar。

compile files('libs/ksoap2-android-assembly-2.5.2-jar-with-dependencies_timeout1.jar')
compile files('libs/ksoap2-j2se-full-2.1.2.jar')

如果有什么请告诉我

【讨论】:

  • 删除libs/ksoap2-android-assembly-2.5.2-jar-with-dependencies_timeout1.jar。收到一条新的错误消息:Error:java.lang.OutOfMemoryError: GC overhead limit exceeded
  • 通过创建一个名为 gradle.properties 的文件并在其中添加以下行来修复它:org.gradle.jvmargs=-Xmx2048m
  • @ZhouHao 如果可能的话,请在此处更新答案,以便其他人可以在需要时跟进。
猜你喜欢
  • 2019-01-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-03-25
  • 1970-01-01
相关资源
最近更新 更多