java - 获取 java.util.zip.ZipException : duplicate entry for SimpleJavaMail

标签 java android gradle jar

在为我的项目构建 apk 时,出现以下错误:

Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/simplejavamail/email/AttachmentResource.class

Here's my gradle file:

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
android {
    compileSdkVersion 24
    buildToolsVersion '24.0.1'

    defaultConfig {
        applicationId "com.parassidhu.cdlumaths"
        minSdkVersion 16
        targetSdkVersion 24
        versionCode 2
        versionName "1.1"
        multiDexEnabled true
    }
    dexOptions {
        incremental true
        javaMaxHeapSize "8g"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles 'proguard-rules.pro'
        }
    }
}
dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    apt 'com.jakewharton:butterknife-compiler:8.0.1'
    compile 'com.android.support:appcompat-v7:24.1.1'
    compile 'com.android.support:design:24.1.1'
    compile 'com.android.support:recyclerview-v7:24.1.1'
    compile 'com.android.support:cardview-v7:24.1.1'
    compile 'com.squareup.retrofit2:retrofit:2.0.2'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.jakewharton:butterknife:8.0.1'
    compile 'com.github.paolorotolo:appintro:3.4.0'
    compile 'com.android.support:support-v4:24.1.1'
    compile 'com.google.android.gms:play-services:9.4.0'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.github.hotchemi:android-rate:1.0.1'
    compile 'com.google.android.gms:play-services-ads:9.4.0'
    compile 'org.simplejavamail:simple-java-mail:4.1.1'
    compile files('libs/simple-java-mail-4.1.1.jar')
}
apply plugin: 'com.google.gms.google-services'

我想我必须改变一些东西

'org.simplejavamail:simple-java-mail:4.1.1'

我不知道出了什么问题。我可以很好地测试应用程序,但是当我重建项目/构建 apk/生成签名 apk 时,我收到此错误。有时,重复的条目指向与 AttachmentResource.class 不同的类。

最佳答案

看起来您两次包含相同的依赖项。

dependencies {
    ...
    compile 'org.simplejavamail:simple-java-mail:4.1.1'
    compile files('libs/simple-java-mail-4.1.1.jar') // <- this is the same jar as your pulling from maven in the line above
}

删除此行并重试编译文件('libs/simple-java-mail:4.1.1')

关于java - 获取 java.util.zip.ZipException : duplicate entry for SimpleJavaMail,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38955250/

相关文章:

java - 声明后初始化数组

java - 按一个字段对 ArrayList<Hashmap<String,String> 进行排序

java - Java 恒定线程循环时间

java - 如何在用户关闭屏幕时暂停游戏

gradle - 无法使用Gradle War插件设置Web URL以包含来自Maven存储库的War

gradle - 有没有办法从组中包含特定模块,同时排除 gradle 中的休息?

java - 将操作放在顶部并同时拆分操作栏

java - 如何存档(使用 Zip)到多个输出文件

android - 来自 EditText 的键盘破坏布局

java - Gradle构建未添加所有 “private”库