[英]ObjectBox DuplicateFileException
We are migrating from ObjectBox 0.9.15 to 1.3.4. 我们正在从ObjectBox 0.9.15迁移到1.3.4。
After updating classes (removing @Relation
, etc) we added dependency for ObjectBox Browser and get following error that appears on build: 更新类(删除
@Relation
等)后,我们为ObjectBox Browser添加了依赖项,并在构建中出现以下错误:
Error:Execution failed for task ':app:transformNativeLibsWithMergeJniLibsForDevelopmentDebug'.
错误:任务':app:transformNativeLibsWithMergeJniLibsForDevelopmentDebug'的执行失败。 com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK lib/armeabi-v7a/libobjectbox.so
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
文件1:/Users/gaket/.android/build-cache/40bfb66d64a6d186c399e949921eb119d45150b8/output/jni
File2: /Users/gaket/.android/build-cache/b30b0ce17a00dfed1ecea8969f4b6fa9a5fe7351/output/jni
文件2:/Users/gaket/.android/build-cache/b30b0ce17a00dfed1ecea8969f4b6fa9a5fe7351/output/jni
Our application consists of two modules: Application
type and Library
type. 我们的应用程序包含两个模块:
Application
类型和Library
类型。 ObjectBox plugin and dependencies are used and declared only in Application
module. 仅在
Application
模块中使用和声明ObjectBox插件和依赖项。 If we change dependency to one without browser, everything works smoothly: 如果我们将依赖关系更改为不带浏览器的依赖关系,那么一切都会顺利进行:
// This works well:
// debugCompile "io.objectbox:objectbox-android-objectbrowser:$objectboxVersion"
debugCompile "io.objectbox:objectbox-android:$objectboxVersion"
releaseCompile "io.objectbox:objectbox-android:$objectboxVersion"
Proguard is turned off, multidex enabled. Proguard已关闭,已启用multidex。
Do you have any idea what could be the problem? 您知道可能是什么问题吗?
Applying plugins: 应用插件:
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'
Dependencies of the Application module: 应用程序模块的依赖关系:
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'
}
}
}
Adding packagingOptions
(details are in docs ) inside android
part of gradle.build
helped. 在
gradle.build
android
部分内添加packagingOptions
(详细信息在docs中 )有帮助。 However, if someone knows cleaner and not so shallow solution, I will be glad to see it. 但是,如果有人知道更清洁而不是那么肤浅的解决方案,我将很高兴看到它。
android {
// some stuff
packagingOptions {
pickFirst 'lib/armeabi-v7a/libobjectbox.so'
pickFirst 'lib/arm64-v8a/libobjectbox.so'
pickFirst 'lib/x86_64/libobjectbox.so'
pickFirst 'lib/x86/libobjectbox.so'
}
}
I decided to leave previous common answer because it can help other people with other libraries. 我决定留下以前的常见答案,因为它可以帮助其他图书馆的人。
Specifically for ObjectBox, the reason is that we should put dependencies before applying the plugin, I missed this point in documentation (in "Setup" block): 专门针对ObjectBox,原因是我们应该在应用插件之前放置依赖项,我在文档中 (“ 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"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.