Android javaMail mergeDebugJavaResource FAILED解决

Java mail 引入这两个jar之后

   implementation 'com.sun.mail:android-mail:1.6.7'
   implementation 'com.sun.mail:android-activation:1.6.7'

build直接报错


> Task :app:mergeDebugJavaResource FAILED
Execution failed for task ':app:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
   > 2 files found with path 'META-INF/NOTICE.md' from inputs:
      - /Users/XXX/.gradle/caches/transforms-3/6575a4fe3e7d00dd7357703987a8a43b/transformed/jetified-android-mail-1.6.7.jar
      - /Users/XXX/.gradle/caches/transforms-3/5ae5624cf1f3cc9ecfb451c4068b1eab/transformed/jetified-android-activation-1.6.7.jar
     Adding a packagingOptions block may help, please refer to
     https://developer.android.com/reference/tools/gradle-api/7.4/com/android/build/api/dsl/ResourcesPackagingOptions
     for more information

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

解决办法

需要在app的build.gradle的android{}里面增加 packagingOptions{} ,内容参考报错日志即可

    packagingOptions {
        exclude 'META-INF/NOTICE.md'
        exclude 'META-INF/LICENSE.md'
    }

你可能感兴趣的:(android)