ObjectBox DuplicateFileException

时间:2018-01-05 02:53:50

标签: java android gradle objectbox

我们正在从ObjectBox 0.9.15迁移到1.3.4。

更新类(删除@Relation等)之后,我们为ObjectBox浏览器添加了依赖项,并在构建时出现以下错误:

  

错误:任务执行失败   ':应用程序:transformNativeLibsWithMergeJniLibsForDevelopmentDebug'。    com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException:重复文件   复制在APK lib / armeabi-v7a / libobjectbox.so

中      

File1中:   /Users/gaket/.android/build-cache/40bfb66d64a6d186c399e949921eb119d45150b8/output/jni

     

文件2:   /Users/gaket/.android/build-cache/b30b0ce17a00dfed1ecea8969f4b6fa9a5fe7351/output/jni

我们的应用程序包含两个模块:Application类型和Library类型。 ObjectBox插件和依赖项仅在Application模块中使用和声明。如果我们将依赖关系更改为没有浏览器的关系,那么一切都会顺利进行:

// This works well:
// debugCompile "io.objectbox:objectbox-android-objectbrowser:$objectboxVersion"
debugCompile "io.objectbox:objectbox-android:$objectboxVersion"
releaseCompile "io.objectbox:objectbox-android:$objectboxVersion"

Proguard已关闭,启用了多指标。

你知道可能出现什么问题吗?

申请插件:

buildscript {
    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
        maven { url "http://objectbox.net/beta-repo/" }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.25.1'
        classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'
        classpath 'com.google.gms:google-services:3.1.2'
        classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.8.2'
        classpath 'io.objectbox:objectbox-gradle-plugin:1.3.4'
        classpath 'me.tatarka:gradle-retrolambda:3.7.0'
        classpath 'com.google.firebase:firebase-plugins:1.1.1'
        classpath 'com.google.gms:google-services:3.1.2'
    }
}

apply plugin: 'com.android.application'
apply plugin: 'com.getkeepsafe.dexcount'
apply plugin: 'io.fabric'
apply plugin: 'com.github.ben-manes.versions'
apply plugin: 'project-report'
apply plugin: 'io.objectbox'
// There are some oddities when retrolambda isn't the last plugin so try to keep it as the last applied plugin
apply plugin: 'me.tatarka.retrolambda'

// Other configs
// Finally
apply from: 'dependencies.gradle'
apply plugin: 'com.google.gms.google-services'

应用程序模块的依赖关系:

ext {
    butterknifeVersion = '8.8.1'
    conductorVersion = '2.1.3'
    daggerVersion = '2.11'
    exoPlayerVersion = 'r2.5.1'
    facebookVersion = '4.24.0'
    firebaseVersion = '11.8.0'
    glideVersion = '4.0.0'
    leakCanaryVersion = '1.5.4'
    logbackVersion = '1.1.1-6'
    okhttpVersion = '3.8.1'
    retrofitVersion = '2.3.0'
    supportVersion = '27.0.2'
    objectboxVersion = '1.3.4'

    dependencies {
        compile project(':vyng-core')

        // UI Libraries
        compile 'com.beloo.widget:ChipsLayoutManager:0.3.7@aar'
        compile 'com.muddzdev:styleabletoast:1.0.9'
        compile "com.github.jarrodholliday:material-about-library:1.8.4"
        compile('com.vdurmont:emoji-java:3.2.0') {
            exclude group: 'org.json', module: 'json'
        }
        compile('eu.davidea:flexible-adapter:5.0.0-rc2') {
            exclude group: 'com.android.support', module: 'design'
        }
        //noinspection GradleCompatible
        compile "com.android.support.constraint:constraint-layout:1.1.0-beta4"

        // Rx Libraries
        compile 'io.reactivex.rxjava2:rxjava:2.1.6'
        compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
        compile 'com.tbruyelle.rxpermissions2:rxpermissions:0.9.4@aar'
        compile 'oxim.digital:rx2anim:0.9.1'
        compile 'com.jakewharton.rxbinding2:rxbinding:2.0.0'

        // Fabric Libraries
        compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
            transitive = true
        }

        //DB libraries
        debugCompile "io.objectbox:objectbox-android-objectbrowser:$objectboxVersion"
        releaseCompile "io.objectbox:objectbox-android:$objectboxVersion"


        // Logger
        compile 'com.jakewharton.timber:timber:4.6.0'
        compile 'org.slf4j:slf4j-api:1.7.25'
        compile "com.github.tony19:logback-android-core:$logbackVersion"
        compile "com.github.tony19:logback-android-classic:$logbackVersion"

        // Util Libraries
        compile 'com.google.code.gson:gson:2.8.2'
        compile 'com.googlecode.libphonenumber:libphonenumber:8.8.1'
        compile "com.facebook.android:facebook-android-sdk:$facebookVersion"
        compile 'com.writingminds:FFmpegAndroid:0.3.2'
        compile 'com.google.guava:guava:23.0-android'

        // Image Libraries
        compile "com.github.bumptech.glide:glide:$glideVersion"
        annotationProcessor "com.github.bumptech.glide:compiler:$glideVersion"
        compile "jp.wasabeef:glide-transformations:3.0.1"
        //compile 'jp.wasabeef:blurry:2.1.1'

        // Support Libraries
        compile "com.android.support:appcompat-v7:$supportVersion"
        compile "com.android.support:design:$supportVersion"
        compile "com.android.support:support-annotations:$supportVersion"

        // Firebase Libraries
        compile "com.google.firebase:firebase-core:$firebaseVersion"
        compile "com.google.firebase:firebase-auth:$firebaseVersion"
        compile "com.google.firebase:firebase-messaging:$firebaseVersion"
        compile "com.google.firebase:firebase-invites:$firebaseVersion"

        // Conductor Libraries
        compile "com.bluelinelabs:conductor:2.1.4"

        // Dependency Injection
        compile "com.google.dagger:dagger:$daggerVersion"
        annotationProcessor "com.google.dagger:dagger-compiler:$daggerVersion"
        provided "javax.annotation:jsr250-api:1.0"
        annotationProcessor "com.jakewharton:butterknife-compiler:$butterknifeVersion"

        //auth
        compile "com.facebook.android:account-kit-sdk:$facebookVersion"

        // Video Libraries
        compile "com.google.android.exoplayer:exoplayer-ui:$exoPlayerVersion"
        compile "com.google.android.exoplayer:exoplayer-core:$exoPlayerVersion"
        compile "com.google.android.exoplayer:exoplayer-dash:$exoPlayerVersion"
        compile "com.yqritc:android-scalablevideoview:1.0.4"

        compile('com.github.jarrodholliday:videocache:2.7.1') {
            exclude module: 'slf4j-android'
            exclude group: 'com.google.android', module: 'android'
        }

        // Networking Libraries
        compile "com.squareup.retrofit2:retrofit:$retrofitVersion"
        compile "com.squareup.retrofit2:converter-gson:$retrofitVersion"
        compile "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion"
        compile "com.squareup.okhttp3:logging-interceptor:$okhttpVersion"
        compile "com.squareup.okhttp3:okhttp:$okhttpVersion"

        // Debug/Testing
        debugCompile "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"
        releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion"
        testCompile "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion"
        testCompile 'junit:junit:4.12'
        testCompile "org.mockito:mockito-core:2.10.0"
        androidTestCompile('com.android.support.test.espresso:espresso-core:3.0.0') {
            exclude module: 'support-annotations'
            exclude group: 'com.google.code.findbugs'
        }
    }
}

2 个答案:

答案 0 :(得分:0)

packagingOptions的{​​{1}}部分内添加android(详情为in docs)有帮助。但是,如果有人知道更清洁,而不是那么浅薄的解决方案,我会很高兴看到它。

gradle.build

答案 1 :(得分:0)

我决定留下以前的常见答案,因为它可以帮助其他人与其他图书馆。

特别是对于ObjectBox,原因是我们应该在应用插件之前放置依赖项,我错过了this point in documentation(在“Setup”块中):

// ObjectBox browser dependencies must be set before applying ObjectBox plugin so it does not add objectbox-android
// (would result in two conflicting versions, e.g. "Duplicate files copied in APK lib/armeabi-v7a/libobjectbox.so").
dependencies {
    debugCompile "io.objectbox:objectbox-android-objectbrowser:$objectboxVersion"
    releaseCompile "io.objectbox:objectbox-android:$objectboxVersion"
}