错误:com.android.builder.merge.DuplicateRelativeFileException:找到了多个文件,它们具有与操作系统无关的路径

时间:2018-10-22 03:53:35

标签: java android gradle android-ndk android-usb

我在应用中使用https://github.com/jiangdongguo/AndroidUSBCamera。我尝试使用示例应用程序自行编译该库,并且该库工作正常,但是将其导入到我的项目中后,我遇到了问题标题中的错误。完整的堆栈跟踪为:

  

失败:构建失败,并出现异常。

     
      
  • 出了什么问题:任务':app:transformNativeLibsWithMergeJniLibsForDebug'的执行失败。

         
        

    使用操作系统独立路径'lib / armeabi / libjpeg-turbo1500.so'找到多个文件

      
  •   
  • 尝试:使用--debug选项运行,以获取更多日志输出。使用--scan运行以获取完整的见解。

  •   
  • 异常是:org.gradle.api.tasks.TaskExecutionException:任务':app:transformNativeLibsWithMergeJniLibsForDebug'的执行失败。   在   org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100)   在   org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70)   在   org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)   在   org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)   在   org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)   在   org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:60)   在   org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97)   在   org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87)   在   org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52)   在   org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)   在   org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)   在   org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)   在   org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)   在   org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker $ 1.run(DefaultTaskGraphExecuter.java:248)   在   org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)   在   org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)   在   org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)   在   org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)   在   org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241)   在   org.gradle.execution.taskgraph.DefaultTaskGraphExecuter $ EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230)   在   org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123)   在   org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.access $ 200(DefaultTaskPlanExecutor.java:79)   在   org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker $ 1.execute(DefaultTaskPlanExecutor.java:104)   在   org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker $ 1.execute(DefaultTaskPlanExecutor.java:98)   在   org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:626)   在   org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:581)   在   org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98)   在   org.gradle.internal.concurrent.ExecutorPolicy $ CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)   在   org.gradle.internal.concurrent.ManagedExecutorImpl $ 1.run(ManagedExecutorImpl.java:46)   在   java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)   在   java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)   在   org.gradle.internal.concurrent.ThreadFactoryImpl $ ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)   在java.lang.Thread.run(Thread.java:745)造成原因:   com.android.builder.merge.DuplicateRelativeFileException:超过   找到一个具有OS无关路径的文件   位于'lib / armeabi / libjpeg-turbo1500.so'   com.android.builder.merge.StreamMergeAlgorithms.lambda $ acceptOnlyOne $ 2(StreamMergeAlgorithms.java:75)   在   com.android.builder.merge.StreamMergeAlgorithms.lambda $ select $ 3(StreamMergeAlgorithms.java:100)   在   com.android.builder.merge.IncrementalFileMergerOutputs $ 1.create(IncrementalFileMergerOutputs.java:86)   在   com.android.builder.merge.DelegateIncrementalFileMergerOutput.create(DelegateIncrementalFileMergerOutput.java:61)   在   com.android.build.gradle.internal.transforms.MergeJavaResourcesTransform $ 1.create(MergeJavaResourcesTransform.java:379)   在   com.android.builder.merge.IncrementalFileMerger.updateChangedFile(IncrementalFileMerger.java:221)   在   com.android.builder.merge.IncrementalFileMerger.mergeChangedInputs(IncrementalFileMerger.java:190)   在   com.android.builder.merge.IncrementalFileMerger.merge(IncrementalFileMerger.java:77)   在   com.android.build.gradle.internal.transforms.MergeJavaResourcesTransform.transform(MergeJavaResourcesTransform.java:411)   在   com.android.build.gradle.internal.pipeline.TransformTask $ 2.call(TransformTask.java:222)   在   com.android.build.gradle.internal.pipeline.TransformTask $ 2.call(TransformTask.java:218)   在   com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102)   在   com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:213)   在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)   在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)   在java.lang.reflect.Method.invoke(Method.java:498)在   org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)在   org.gradle.api.internal.project.taskfactory.IncrementalTask​​Action.doExecute(IncrementalTask​​Action.java:46)   在   org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39)   在   org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26)   在   org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter $ 1.run(ExecuteActionsTaskExecuter.java:121)   在   org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)   在   org.gradle.internal.progress.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)   在   org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)   在   org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)   在   org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)   在   org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)   ... 32更多

  •   

jniLib有四个子目录:arm64-v8a,armeabi,armeabi-v7a,x86;每个文件都包含四个.so文件:libjpeg-turbo1500.so,libusb100.so,libuvc.so,libUVCCamera.so 现在,如果我通过排除'lib / armeabi /#filename#.so'排除所有.so文件,则该项目可以正常构建和运行,但是相机功能将无法正常工作,因为它是在ndk中实现的。

该库的

build.gradle如下:

apply plugin: 'com.android.library'
apply plugin: 'com.github.dcendents.android-maven'
group = 'com.github.jiangdongguo'

android {
    compileSdkVersion 25
    buildToolsVersion '26.0.2'

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/project.properties'
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        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/builddef.lst'
        exclude 'META-INF/ASL2.0'
        exclude 'META-INF/maven/commons-lang/commons-lang/pom.xml'
        exclude 'META-INF/maven/commons-lang/commons-lang/pom.properties'
        exclude 'META-INF/mailcap.default'
        exclude 'typedefs.txt'
        exclude 'META-INF/maven'
    }

    dexOptions {
        preDexLibraries = false
        javaMaxHeapSize "5g"
    }

}


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'
    })
    implementation 'com.android.support:appcompat-v7:25.3.1'
    testCompile 'junit:junit:4.12'
    implementation("com.serenegiant:common:${commonLibVersion}") {
        exclude module: 'support-v4'
    }
}

我已经尝试在所有.so文件上使用pickFirst排除很多元infs,尝试所有* .exclude组:'com.android.support',模块:'support-v7',尝试删除实现fileTree。我确实使现金/重新启动,清理项目,重建项目无效,没有任何结果。 还有什么我可以尝试的?

我的项目级别奖励是:

buildscript {
    repositories {
        jcenter()
        maven {
            url 'https://maven.google.com/'
            name 'Google'
        }
        google()
    }
    dependencies {
        classpath 'com.google.gms:google-services:2.1.0'
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
        mavenCentral()
        maven { url "https://jitpack.io" }
        maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
        google()
        maven { url 'http://raw.github.com/saki4510t/libcommon/master/repository/' }
    }
}



ext {
    commonLibVersion= '1.5.20'
    compileSdkVersion = 27
    buildToolsVersion = '27.0.3'
    minSdkVersion = 21
    versionName = "1.7.0"
    versionCode = 1
    multiDexEnabled = true
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

应用级别的收益是:

apply plugin: 'com.android.application'

android {
    signingConfigs {
        release {
            keyAlias 'alias_name'
            keyPassword 'Mine2017'
            storeFile file('release.keystore')
            storePassword 'Mine2017'
        }
        debug {
            keyAlias 'alias_name'
            keyPassword 'Mine2017'
            storeFile file('release.keystore')
            storePassword 'Mine2017'
        }
    }

    compileSdkVersion rootProject.ext.compileSdkVersion
    buildToolsVersion rootProject.ext.buildToolsVersion

    defaultConfig {
        applicationId "com.rit.andrey.service"
        minSdkVersion rootProject.ext.minSdkVersion
        versionCode rootProject.ext.versionCode
        versionName rootProject.ext.versionName
        multiDexEnabled rootProject.ext.multiDexEnabled
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
        debug {
        }
    }
    compileOptions {
        targetCompatibility 1.8
        sourceCompatibility 1.8
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    //implementation files('libs/stickygridheaders.jar')
    implementation 'com.tonicartos:stickygridheaders:1.0.1'
    implementation 'org.osmdroid:osmdroid-android:5.5:release@aar'
    implementation project(':mmlib')
    implementation project(':usbSerialForAndroid-release')
    implementation 'commons-io:commons-io:2.5'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    }
    implementation project(':libstreaming')
    implementation project(':aemdriver-release')
    implementation 'com.android.support:appcompat-v7:25.3.0'
    implementation 'com.github.PhilJay:MPAndroidChart:v3.0.2'
    implementation 'com.jakewharton:butterknife:8.7.0'
    implementation 'com.google.guava:guava:16.0.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.1'
    annotationProcessor 'com.jakewharton:butterknife-compiler:8.7.0'
    implementation 'com.android.support:recyclerview-v7:25.3.0'
    implementation 'com.google.android.gms:play-services-location:9.0.2'
    implementation 'com.android.support:design:25.3.0'

    //Logger
    implementation 'org.slf4j:slf4j-api:1.7.21'
    implementation 'com.github.tony19:logback-android-core:1.1.1-6'
    implementation('com.github.tony19:logback-android-classic:1.1.1-6') {
        // workaround issue #73
        exclude group: 'com.google.android', module: 'android'
    }
    implementation 'com.github.japgolly.android:svg-android:2.0.6'
    implementation project(path: ':utm')
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.github.jiangdongguo:AndroidUSBCamera:2.2.8'
    implementation project(':libcamera')
}

configurations.all {
    resolutionStrategy.eachDependency { DependencyResolveDetails details ->
        def requested = details.requested
        if (requested.group == 'com.android.support') {
            if (!requested.name.startsWith("multidex")) {
                details.useVersion '25.3.0'
            }
        }
    }
}

0 个答案:

没有答案