2016-08-09 52 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

我做到了,但现在我得到了另一个错误,我用堆栈跟踪更新我的问题。 –

相关问题