简体   繁体   English

错误:com.android.dex.DexException:多个dex文件定义了Ledu / umd / cs / findbugs / annotations / NonNull;

[英]Error:com.android.dex.DexException: Multiple dex files define Ledu/umd/cs/findbugs/annotations/NonNull;

My module dependencies: 我的模块依赖项:

configurations.all {
    resolutionStrategy {
        force 'junit:junit:4.12'
    }
}

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:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'

provided 'org.projectlombok:lombok:1.16.16'
annotationProcessor "org.projectlombok:lombok:1.16.16"

// For DL4J
compile 'org.deeplearning4j:deeplearning4j-core:0.9.1'
compile 'org.deeplearning4j:deeplearning4j-zoo:0.9.1'
compile 'org.nd4j:nd4j-native:0.9.1'
compile 'org.nd4j:nd4j-native:0.9.1:android-arm'
compile 'org.bytedeco.javacpp-presets:openblas:0.2.19-1.3:android-arm'
compile project(':dlbenchmark')
}

dlbenchmark dependencies are as below: dlbenchmark依赖关系如下:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    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:25.3.1'
testCompile 'junit:junit:4.12'
}

Whole project gradle file: 整个项目的gradle文件:

buildscript {
    repositories {
        jcenter()
        google()
    }
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}
allprojects {
    repositories {
        jcenter()
        google()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

dependencies {
}

and when building dl4j module in Android Studio I got an error: 在Android Studio中构建dl4j模块时出现错误:

Error:java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex 错误:java.lang.RuntimeException:java.lang.RuntimeException:com.android.builder.dexing.DexArchiveMergerException:无法合并dex

Error:com.android.dex.DexException: Multiple dex files define Ledu/umd/cs/findbugs/annotations/NonNull; 错误:com.android.dex.DexException:多个dex文件定义了Ledu / umd / cs / findbugs / annotations / NonNull;

How can I fix this? 我怎样才能解决这个问题?

As the error message says there are multiple definitions for some classes. 如错误消息所示,某些类有多个定义。 I faced the same problem and was able to solve it by looking at the dependency tree. 我遇到了同样的问题,通过查看依赖关系树就可以解决它。

If you run 如果你跑

./gradlew app:dependencies

in the Android studio terminal, you will get a dependency tree. 在Android Studio终端中,您将获得一个依赖关系树。 You will find 你会找到

com.google.code.findbugs:annotations:2.0.1

This library is required for testing and need not be packed with your apk. 该库是测试所必需的,不需要与您的apk一起打包。 You can exclude it from your dependencies like this: 您可以像这样从依赖中排除它:

compile('org.nd4j:nd4j-native:0.9.1') {
    exclude group: 'com.google.code.findbugs', module: 'annotations'

}

compile('org.nd4j:nd4j-native:0.9.1:android-x86')
        {
            exclude group: 'com.google.code.findbugs', module: 'annotations'

        }
compile('org.nd4j:nd4j-native:0.9.1:android-arm')
        {
            exclude group: 'com.google.code.findbugs', module: 'annotations'

        }

Now try to build and see if it works. 现在尝试构建并查看它是否有效。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将字节码转换为dex时出错:原因:com.android.dex.DexException:多个dex文件定义了Lcom / RNFetchBlob / RNFetchBlobConst; - Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/RNFetchBlob/RNFetchBlobConst; 将字节码转换为dex:原因:com.android.dex.DexException:定义了多个dex文件 - converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define com.android.dex.DexException:多个dex文件定义了Lcom / google / android / gms / location / places / PlaceReport; - com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/location/places/PlaceReport; com.android.dex.DexException:多个dex文件定义了Lcom / facebook / internal / Utility $ GraphMeRequestWithCacheCallback; - com.android.dex.DexException: Multiple dex files define Lcom/facebook/internal/Utility$GraphMeRequestWithCacheCallback; com.android.dex.DexException:多个dex文件定义Lorg / hamcrest / Description; - com.android.dex.DexException: Multiple dex files define Lorg/hamcrest/Description; 意外的顶级异常:com.android.dex.DexException:多个dex文件定义 - UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define 意外的顶级异常:com.android.dex.DexException:多个dex文件定义 - UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dex.DexException: Multiple dex files define Gradle 构建错误将字节码转换为 dex 时出错:原因:com.android.dex.DexException:多个 dex 文件定义 Landroid/arch/lifecycle/liveData$1 - Gradle build error Error converting bytecode to dex:Cause: com.android.dex.DexException:Multiple dex files define Landroid/arch/lifecycle/liveData$1 错误:将字节码转换为dex时出错:原因:com.android.dex.DexException:多个dex文件定义了Lcom / google / android / gms / common / api / zza; - Error:Error converting bytecode to dex: Cause: com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/common/api/zza; 未知源文件:com.android.dex.DexException:多个dex文件定义了Lcom / google / android / gms / internal / zzpq; - Unknown source file : com.android.dex.DexException: Multiple dex files define Lcom/google/android/gms/internal/zzpq;
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM