我们正在从ObjectBox 0.9.15迁移到1.3.4。
在更新类(删除@Relation
等)之后,我们为ObjectBox Browser添加了依赖项,并获得了构建中出现的跟随错误:
错误:任务':app:transformNativeLibsWithMergeJniLibsForDevelopmentDebug'的执行失败。 com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException:在APK lib / armeabi-v7a / libobjectbox.so中复制的重复文件
Phil1:/Users/Jackets/.android/build-cash/40bfb66rd64a6r186k399e949921be1194545508_8/output/geni
File2:/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'
}
}
}
在packagingOptions
的in docs部分内添加android
(细节是gradle.build
)帮助。但是,如果有人知道更清洁而不是那么浅薄的解决方案,我会很高兴看到它。
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'
}
}
我决定留下以前的共同答案,因为它可以帮助其他人与其他图书馆。
特别是对于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"
}