报错

今天在引入 jdsp 这个库是,直接使用 implementation 'com.github.psambit9791:jdsp:1.0.0',结果 androidstudio 报错如下:

Duplicate class org.apache.maven.surefire.report.SafeThrowable found in modules jetified-common-java5-2.19.1 (org.apache.maven.surefire:common-java5:2.19.1) and jetified-surefire-api-2.19.1 (org.apache.maven.surefire:surefire-api:2.19.1)
Duplicate class org.apache.maven.surefire.report.StackTraceWriter found in modules jetified-common-java5-2.19.1 (org.apache.maven.surefire:common-java5:2.19.1) and jetified-surefire-api-2.19.1 (org.apache.maven.surefire:surefire-api:2.19.1)

解决

经过搜索,实验,解决方法在 build.gradle 中修改如下:

android {
...
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE.md'
        exclude 'META-INF/LICENSE-notice.md'
    }

}

dependencies {
...
    implementation('com.github.psambit9791:jdsp:1.0.0') {
        exclude group: 'org.apache.maven.surefire', module: 'common-java5'
        exclude group: 'org.apache.maven.surefire', module: 'surefire-api'
    }

}

参考:

Duplicate class SafeThrowable or StackTraceWriter #11
https://github.com/psambit9791/jDSP/issues/11
Dependency resolution error #5
https://github.com/psambit9791/jDSP/issues/5

标签: application

添加新评论