Java 邮件 API 错误;重复条目:javax/mail/MultipartDataSource.class

Java Mail API error; duplicate entry: javax/mail/MultipartDataSource.class

在生成签名 APK 时,出现此错误。我正在通过项目中的 Java 邮件 API 通过 Gmail 发送电子邮件。 当 运行 它在 phone 上时没有错误,但是当尝试生成 apk 时会出现以下错误。谢谢。

Error:Execution failed for task ':app:transformClassesWithJarMergingForRelease'.> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: javax/mail/MultipartDataSource.class

The error message

这是我的 gradle 依赖项;

    dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile files('./libs/ZSDK_ANDROID_API.jar')
    compile 'com.google.android.gms:play-services:8.4.0'
    compile 'com.google.code.ksoap2-android:ksoap2-android-assembly:3.6.1'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'

    testCompile 'junit:junit:4.12'
    compile files('libs/activation.jar')
    compile files('libs/javax.mail.jar')


}

这是我的 Mail.class

public boolean send() throws Exception {
    Properties props = _setProperties();

    if (!user.equals("") && !pass.equals("") && !to.equals("")
            && !from.equals("") && !subject.equals("")
            && !body.equals("")) {
        Session session = Session.getInstance(props, this);

        MimeMessage msg = new MimeMessage(session);

        msg.setFrom(new InternetAddress(from)); 
        msg.setRecipients(MimeMessage.RecipientType.TO,to);

        msg.setSubject(subject);
        msg.setSentDate(new Date());

        // setup message body
        MimeBodyPart messageBodyPart = new MimeBodyPart();
        messageBodyPart.setText(body.toString());
        multipart.addBodyPart(messageBodyPart);

        msg.setHeader("X-Priority", "1");
        msg.setContent(multipart);

        Transport.send(msg);

        return true;
    } else {
        return false;
    }
}

问题,lib 文件夹中有一些未使用的库。按照@IntelliJAmiya 的建议,删除它们并解决问题。