我使用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:\AndroidStudio\CobaEmailGuard\app\libs\dsn.jar
File2: C:\AndroidStudio\CobaEmailGuard\app\libs\mail.jar
File3: C:\AndroidStudio\CobaEmailGuard\app\libs\mailapi.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'
}
}
是grandle中的错误还是放错位置的jars文件?
发布于 2017-02-03 05:36:40
您不需要同时使用mail.jar和mailapi.jar,如JavaMail NOTES.txt文件中所述;只需使用mail.jar。JavaMail Android page还提供了一个gradle构建示例。
https://stackoverflow.com/questions/41997280
复制相似问题