在Android Android

时间:2017-07-12 15:22:35

标签: android gradle dl4j

在尝试编译我的Android项目时,我遇到了“在APK中复制的重复文件”问题。

Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK org/bytedeco/javacpp/windows-x86/msvcp120.dll
    File1: C:\Users\yuh5\.gradle\caches\modules-2\files-2.1\org.bytedeco.javacpp-presets\opencv\3.1.0-1.3\3d455d0c218e90072827d5b22b4163b1eea323e9\opencv-3.1.0-1.3-windows-x86.jar
    File2: C:\Users\yuh5\.gradle\caches\modules-2\files-2.1\org.bytedeco.javacpp-presets\hdf5\1.10.0-patch1-1.3\76b579910f51cd628bed8f6cbb245670483b9eeb\hdf5-1.10.0-patch1-1.3-windows-x86.jar

它说这是因为msvcp120.dll包含在两个地方,但我不知道为什么以及怎么做'exclude'或'pickfirst'来摆脱这个错误。

我的gradle脚本:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "25.0.1"

    defaultConfig {
        applicationId "com.yuh5.nih.testall"
        minSdkVersion 19
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

    packagingOptions {
        exclude 'META-INF/DEPENDENCIES.txt'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/dependencies.txt'
        exclude 'META-INF/INDEX.LIST'
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:23.2.1'
    compile project(':libraries:opencv')
    compile ('org.deeplearning4j:deeplearning4j-core:0.8.0'){
        exclude group: 'org.json', module: 'json'
    }
    compile 'org.nd4j:nd4j-native:0.8.0'
    compile 'org.nd4j:nd4j-native:0.8.0:android-arm'

}

1 个答案:

答案 0 :(得分:0)

packagingOptions

中添加此内容
 pickFirst 'org/bytedeco/javacpp/windows-x86/msvcp120.dll'