com.android.builder.packaging.DuplicateFileException:复制在META-INF / maven / com.fasterxml.jackson.core / jackson-databind / pom.xml中复制的文件 [英] com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/com.fasterxml.jackson.core/jackson-databind/pom.xml

查看:719
本文介绍了com.android.builder.packaging.DuplicateFileException:复制在META-INF / maven / com.fasterxml.jackson.core / jackson-databind / pom.xml中复制的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个使用RestAPI获取数据的应用程序,并且为此操作我使用了retrofit 2,okhttp3和jackson来解析json以便对象,我的应用程序也使用Firebase Cloud Messaging



当我编译我的代码时,它给了我下面的错误&我无法运行它。



错误:任务执行失败:app:transformResourcesWithMergeJavaResForDebug'。


com.android.build.api.transform.TransformException:com.android.builder.packaging.DuplicateFileException:在APK中复制的重复文件META-INF / maven / com.fasterxml.jackson.core / jackson -databind / pom.xml
File1:/Users/silent/work/silentinfotech/DoorEye/app/libs/jackson-databind-2.7.2.jar
File2:/Users/silent/.gradle/ caches / modules-2 / files-2.1 / com.fasterxml.jackson.core / jackson-databind / 2.2.2 / 3c8f6018eaa72d43b261181e801e6f8676c16ef6 / jackson-databind-2.2.2.jar

我正在使用 Android Studio 2.1.1 OS X EI Capitan 10.11.2



某些库添加到项目库文件夹中



converter-jackson-2.0.2.jar



jackson-annotations-2.7.0.jar

jackson-core-2.7.2.jar





我的build.gradle文件

  apply plugin:'com.android。应用程序'

android {
compileSdkVersion 23
buildToolsVersion23.0.2

defaultConfig {
applicationIdcom.silentinfotech.dooreye
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName1.0
multiDexEnabled true
}
buildTypes {
release {
minify启用false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
packagingOptions {

排除'META-INF / LICENSE'
不包括'META-INF / NOTICE'

}
}

依赖关系{
编译fileTree包括:['* .jar'],dir:'libs')
testCompile'junit:junit:4.12'
compile'c​​om.android.support:appcompat-v7:23.4.0'
//编译'com.android.support:support-v4:23.4.0'
编译'com.google.firebase:firebase-messaging:9.0.0'
编译'com.firebase: firebase-client-android:2.5.1+'
// compile'c​​om.github.bumptech.glide:glide:3.7.0'
compile'c​​om.squareup.retrofit2:retrofit:2.0.2 '
compile'c​​om.squareup.okhttp3:okhttp:3.2.0'
compile'c​​om.squareup.okhttp3:logging-interceptor:3.0.1'

}
应用插件:'com.google.gms.google-s ervices'

我也尝试在build.gradle文件中添加以下内容,但它对我无效

  packagingOptions {
不包括'META-INF / LICENSE'
不包括'META-INF / NOTICE'
}

也尝试无效缓存&重新启动,并重建,干净,即使我尝试手动删除缓存但仍然给我错误

我正在使用firebase云消息在我的项目中,当我删除所有Firebase云消息传递的依赖性,然后项目成功运行,但是当我添加FCM依赖性时,它总是会给出错误

>

  packagingOptions {

排除'META-INF / LICENSE'
排除'META-INF / NOTICE '

}

试试这个

  packagingOptions {

排除'META-INF / DEPENDENCIES.txt'
排除'META-INF / LICENSE.txt'
排除'META-INF / NOTICE.txt'
排除'META-INF / NOTICE'
排除'META-INF / LICENSE'
排除'META-INF / DEPENDENCIES'
排除'META-INF / notice.txt'
排除'META-INF / license.txt'
排除' META-INF / dependencies.txt'
exclude'META-INF / LGPL2.1'

}

以及更多东西



删除此行

  apply bottom:'com.google.gms.google-services'

并在此 apply apply plugin:'com.android.application'之后添加到顶部。

  apply plugin:'com.android.application'
apply plugin:'com.google.gms.google-服务'



更新:





  compile fileTree(dir:'libs',include:'* .jar')

并应用相关性。

i am creating one app that uses a RestAPI to fetch data , and for that operation i am using retrofit 2 , okhttp3 and jackson for parsing json to object , my app also use Firebase Cloud Messaging

when i compile my code it gives me following error & i can't able to run it

Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.

com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/maven/com.fasterxml.jackson.core/jackson-databind/pom.xml File1: /Users/silent/work/silentinfotech/DoorEye/app/libs/jackson-databind-2.7.2.jar File2: /Users/silent/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.core/jackson-databind/2.2.2/3c8f6018eaa72d43b261181e801e6f8676c16ef6/jackson-databind-2.2.2.jar

i am using Android Studio 2.1.1 and OS X EI Capitan 10.11.2

some Library added in projects libs folder

converter-jackson-2.0.2.jar

jackson-annotations-2.7.0.jar

jackson-core-2.7.2.jar

jackson-databind-2.7.2.jar

My build.gradle file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.silentinfotech.dooreye"
        minSdkVersion 17
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        multiDexEnabled true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {

        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'

    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
   // compile 'com.android.support:support-v4:23.4.0'
    compile 'com.google.firebase:firebase-messaging:9.0.0'
    compile 'com.firebase:firebase-client-android:2.5.1+'
   // compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.squareup.retrofit2:retrofit:2.0.2'
    compile 'com.squareup.okhttp3:okhttp:3.2.0'
    compile 'com.squareup.okhttp3:logging-interceptor:3.0.1'

}
apply plugin: 'com.google.gms.google-services'

I also tried adding following in my build.gradle file but it don't work for me

    packagingOptions {
    
        
exclude 'META-INF/LICENSE'
        
exclude 'META-INF/NOTICE'
    
    
}

also tried invalidate caches & restart , and also rebuild , clean , even i tried with manually deleting caches but still its give me error

i am using firebase Cloud messaging in my project when i remove all the dependancy of Firebase Cloud Messaging then project successfully run but when i add FCM dependancy it always give error

解决方案

Instead of this

packagingOptions {

        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'

    }

try this

 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'

   }

and more thing

Remove this line

apply plugin: 'com.google.gms.google-services'

from Bottom and add to Top after this apply plugin: 'com.android.application'.

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'

Update :

just remove

compile fileTree(dir: 'libs', include: '*.jar')

and apply dependencies.

这篇关于com.android.builder.packaging.DuplicateFileException:复制在META-INF / maven / com.fasterxml.jackson.core / jackson-databind / pom.xml中复制的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆