2016-08-09 30 views
2

我試圖創建自己的Android應用程序,但是當我嘗試運行應用程序,我碰到下面的錯誤在APK META-INF /服務複製Android的重複文件/

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/services/com.fasterxml.jackson.databind.Module 
    File1: /home/eric/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.datatype/jackson-datatype-jsr310/2.7.3/e41a3c103f5017794bd866528ec359ae70f5f875/jackson-datatype-jsr310-2.7.3.jar 
    File2: /home/eric/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.datatype/jackson-datatype-jdk8/2.7.3/2390f30d097229e043a0bde30fa1ba8f9b0d951b/jackson-datatype-jdk8-2.7.3.jar 
    File3: /home/eric/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.datatype/jackson-datatype-guava/2.7.3/7fa709967be660a704d8b42e43d6811bf52a83fc/jackson-datatype-guava-2.7.3.jar 
    File4: /home/eric/.gradle/caches/modules-2/files-2.1/com.fasterxml.jackson.module/jackson-module-afterburner/2.7.3/27b8222af569ecd9e718fa7e697fbb22045a98c4/jackson-module-afterburner-2.7.3.jar 

這個錯誤是駕駛我瘋了,我做了很多的搜索,但沒有工作對我來說,大多數情況下的人建議使用packagingOptions和排除META-INF我想這一個例子:

packagingOptions { 
     exclude 'META-INF/services' 
    } 

你們能幫助我?

UPDATE

我添加了TML的建議,現在我發現了以下錯誤

Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.dom4j.dom.DOMNodeHelper$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.dom4j.io.DocumentInputSource$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.dom4j.rule.RuleManager$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.dom4j.swing.LeafTreeNode$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.dom4j.swing.BranchTreeNode$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:warning: Ignoring InnerClasses attribute for an anonymous inner class 
Error:(org.dom4j.xpath.DefaultXPath$1) that doesn't come with an 
Error:associated EnclosingMethod attribute. This class was probably produced by a 
Error:compiler that did not target the modern .class file format. The recommended 
Error:solution is to recompile the class from source, using an up-to-date compiler 
Error:and without specifying any "-target" type options. The consequence of ignoring 
Error:this warning is that reflective operations on this class will incorrectly 
Error:indicate that it is *not* an inner class. 
Error:trouble processing "javax/xml/parsers/DocumentBuilder.class": 
Error:Ill-advised or mistaken usage of a core class (java.* or javax.*) 
Error:when not building a core library. 
Error:This is often due to inadvertently including a core library file 
Error:in your application's project, when using an IDE (such as 
Error:Eclipse). If you are sure you're not intentionally defining a 
Error:core class, then this is the most likely explanation of what's 
Error:going on. 
Error:However, you might actually be trying to define a class in a core 
Error:namespace, the source of which you may have taken, for example, 
Error:from a non-Android virtual machine project. This will most 
Error:assuredly not work. At a minimum, it jeopardizes the 
Error:compatibility of your app with future versions of the platform. 
Error:It is also often of questionable legality. 
Error:If you really intend to build a core library -- which is only 
Error:appropriate as part of creating a full virtual machine 
Error:distribution, as opposed to compiling an application -- then use 
Error:the "--core-library" option to suppress this error message. 
Error:If you go ahead and use "--core-library" but are in fact 
Error:building an application, then be forewarned that your application 
Error:will still fail to build or run, at some point. Please be 
Error:prepared for angry customers who find, for example, that your 
Error:application ceases to function once they upgrade their operating 
Error:system. You will be to blame for this problem. 
Error:If you are legitimately using some code that happens to be in a 
Error:core package, then the easiest safe alternative you have is to 
Error:repackage that code. That is, move the classes in question into 
Error:your own package namespace. This means that they will never be in 
Error:conflict with core system classes. JarJar is a tool that may help 
Error:you in this endeavor. If you find that you cannot do this, then 
Error:that is an indication that the path you are on will ultimately 
Error:lead to pain, suffering, grief, and lamentation. 
Error:1 error; aborting 
Error:Execution failed for task ':app:transformClassesWithDexForDebug'. 
> com.android.build.api.transform.TransformException: java.lang.RuntimeException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Return code 1 for dex process 
Information:BUILD FAILED 
Information:Total time: 19.099 secs 
Error:Error converting bytecode to dex: 
Cause: Dex cannot parse version 52 byte code. 
This is caused by library dependencies that have been compiled using Java 8 or above. 
If you are using the 'java' gradle plugin in a library submodule add 
targetCompatibility = '1.7' 
sourceCompatibility = '1.7' 
to that submodule's build.gradle file. 
Error:1 error; aborting 
+0

現在這是一個完全不同的問題。你應該開始一個新的問題,並接受這個原始問題的答案。 – TWL

回答

2

我剛剛有幾乎完全相同的問題。

添加此代碼,就像TML說,解決了這個問題對我來說:

android { 

    packagingOptions { 
     exclude 'META-INF/services/com.fasterxml.jackson.databind.Module' 
    } 

} 
0

使用您的build.gradle文件中以下行下面buildTypes: -
packagingOptions { exclude 'META-INF/NOTICE.txt' // will not include NOTICE file exclude 'META-INF/LICENSE.txt' // will not include LICENSE file } 並在同一文件中添加defaultConfig

multiDexEnabled true

希望這會幫助你。 如果這對你有幫助,請給我投票。

1

我只是幫助別人類似的問題:Android Gradle Duplicate files copied in APK META-INF

每當你看到Exception: Duplicate files copied in APK BLAH/blaha.blahb.blahc

另一個exclude 'BLAH/blaha.blahb.blahc'添加到您的

所以你的情況:exclude 'META-INF/services/com.fasterxml.jackson.databind.Module'

此異常可能發生很多次,直到你抓住他們!

+0

我做到了,但現在我得到了另一個錯誤,我用堆棧跟蹤更新我的問題。 –

相關問題