我已经研究了stackoverflow中的所有类似情况,但是提出的解决方案似乎非常具体,完全取决于gradle文件中声明的依赖项的组合。
我设法成功构建,但是当我尝试运行App时,我得到:
错误:任务':app:transformResourcesWithMergeJavaResForDebug'执行失败。
com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException:在APK com / fasterxml / jackson / core / json / VERSION.txt中复制的重复文件
文件1: /media/barmistias/9668C07068C050A3/AndroidApps/LMMovies/app/libs/jackson-core-2.1.3.jar
文件2: /home/barmistias/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-core/2.1.3/f6c3aed1cdfa21b5c1737c915186ea93a95a58bd/jackson-核 - 2.1.3.jar
我的Gradle文件是:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.0'
defaultConfig {
applicationId "com.languagematerial.lmmovies"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
repositories{
mavenCentral()
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:27.0.0'
compile 'com.android.support:recyclerview-v7:27.0.0'
compile 'com.android.support:support-media-compat:27.0.0'
compile 'com.android.support:support-v4:27.0.0'
android {
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
}
compile 'com.android.support:multidex:1.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
compile 'org.apmem.tools:layouts:1.10@aar'
compile 'com.github.wseemann:FFmpegMediaMetadataRetriever:1.0.14'
compile 'com.nononsenseapps:filepicker:4.1.0'
compile 'org.apache.commons:commons-io:1.3.2'
testCompile 'junit:junit:4.12'
compile files('libs/YouTubeAndroidPlayerApi.jar')
compile 'pub.devrel:easypermissions:0.3.0'
compile('com.google.api-client:google-api-client-android:1.23.0') {
exclude group: 'org.apache.httpcomponents'
}
compile('com.google.apis:google-api-services-youtube:v3-rev186-1.23.0') {
exclude group: 'org.apache.httpcomponents'
}
compile 'com.squareup.picasso:picasso:2.5.2'
}
解决问题最常用的建议是:
packagingOptions{
exclude 'META-INF/VERSION' // or: pickfirst...?
exclude 'META-INF/VERSION.txt'
exclude 'META-INF/version.txt'
}
在我的情况下,错误仍然存在,更糟糕的是,当编译器找不到必要的文件时,会出现新错误。 一个问题:使用 pickfirst 类型指令而不是排除指令会更好吗?那么,有什么想法吗?感谢。
答案 0 :(得分:0)
而不是这个
packagingOptions {
exclude 'META-INF/VERSION' // or: pickfirst...?
exclude 'META-INF/VERSION.txt'
exclude 'META-INF/version.txt'
}
试试这个
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/LGPL2.1'
}