java - Android Studio 构建错误 : More than one file was found with OS independent path 'META-INF/gfprobe-provider.xml'

标签 java android-studio jakarta-mail

我正在构建一个简单的 Android 应用程序,用户可以在其中发送/接收电子邮件。我正在使用java邮件API。我的代码在 Eclipse 中运行良好,但现在我使用 Android Studio,我收到构建错误。

一个答案建议我将其添加到我的 build.gradle 文件中。但这并没有帮助

android {      
      packagingOptions {
        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'
      }          
}

这是我的 build.gradle 文件

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.javaemailapp"
        minSdkVersion 24
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.0.2'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.0.0'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
    implementation files('/Users/redacted/Downloads/javamail-1.4.4/mail.jar')
    implementation files('/Users/redacted/Downloads/jaf-1.1.1/activation.jar')
}

我只是想测试并查看“发送”按钮在我的应用程序中是否有效,但是当我在 Android Studio 中单击“运行”时,我收到此错误:

发现多个文件具有独立于操作系统的路径“META-INF/gfprobe-provider.xml”

最佳答案

使用更新版本的 JavaMail for Android .

关于java - Android Studio 构建错误 : More than one file was found with OS independent path 'META-INF/gfprobe-provider.xml' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58702315/

相关文章:

java - Selenium 屏幕捕获 - 图像不可用

java - 在 Groovy 中将可变长度字符串散列为 12 位数字的一种方法函数

java - 当我尝试在 android studio 中调试时卡在收集数据中

java - 使用Java发送电子邮件时如何防止调试代码?

java - 通过保持文本位置在 Java 中阅读电子邮件

java - 创建可以采用多种不同模型类型的通用对象

java - 我无法将其与 Jpanel 的右侧部分对齐

android - 在 Android Studio 3.1 中将问题从 Gradle 3 迁移到 4

Android Studio 项目需要旧版本的 Gradle

java - 是否有任何解决方案可以通过使用 POP 在 Java 中传递特定电子邮件消息 ID 来下载电子邮件附件?