我尝试通过Gmail发送邮件,但它会产生错误。当我构建我的应用程序时,我没有错误但是当我运行我的应用程序时它会出现以下错误
在操作系统独立路径'META-INF / mailcap.default'中找到了多个文件
我尝试了很多东西,但没解决,所以请帮忙。 谢谢
我的app build.gradle文件是
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.user.mysqldatabaseapp"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
pickFirst 'META-INF/LICENSE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.volley:volley:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.sun.mail:javax.mail:1.6.1'
implementation 'com.sun.mail:android-activation:1.6.1'
}
答案 0 :(得分:1)
这是因为您的包中包含多个包含META-INF/mailcap.default
的依赖项。因此,您只需添加META-INF/mailcap.default
行,即可使用pickFirst
中的一个。像这样:
packagingOptions {
// use only one
pickFirst 'META-INF/mailcap.default'
pickFirst 'META-INF/LICENSE.txt'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}