>我使用 Android Studio 创建了一个发送电子邮件应用程序,我使用 javamail 发送电子邮件,但是当我尝试构建和调试应用程序时会出现这样的错误
Error:FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/mailcap
File1: C:AndroidStudioCobaEmailGuardapplibsdsn.jar
File2: C:AndroidStudioCobaEmailGuardapplibsmail.jar
File3: C:AndroidStudioCobaEmailGuardapplibsmailapi.jar
这是我的build.grandle(模块:app)
apply plugin: 'com.android.application'
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 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
compile files('libs/mail.jar')
}
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.example.eladoktarizo.cobaemailguard"
minSdkVersion 14
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt' exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
无论是格兰德尔中的错误还是放错位置的 jars 文件?
您不需要 mail.jar 和 mailapi.jar,如 JavaMail NOTES.txt 文件中所述;只需使用 mail.jar。 JavaMail Android页面也有一个gradle构建示例。