欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

java.util.zip.ZipException: duplicate entry: org/apache/xmlbeans/xml/stream/Location.class

程序员文章站 2022-04-09 17:29:14
...

先说下问题的缘由吧,我是想在自己软件中预览word等文档,网上找了很多种方法,发现其他的虽然都可以实现,也挺好的,但要不就是很麻烦,就是要付费。最后我是打算采用poi,虽然缺点是体验不太好,但没办法,为了是实现功能,我还是都是那采用它。但遇到的下面这个问题,把我搞得有点头疼,国内关于这个的解决办法,很少,找了半天,都是在*上看到有人回答,但是我试了很多,依旧不能解决我的问题。

:ols:incrementalDebugJavaCompilationSafeguard UP-TO-DATE
:ols:compileDebugJavaWithJavac UP-TO-DATE
:ols:compileDebugNdk UP-TO-DATE
:ols:compileDebugSources UP-TO-DATE
:ols:prePackageMarkerForDebug
:ols:transformClassesWithJarMergingForDebug FAILED
Error:Execution failed for task ':ols:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/apache/xmlbeans/xml/stream/Location.class

这个错误找了好久。把问题记录下吧
在网上找了各种,反正最近的解决办法也是莫名其妙。
*上的解释也是各种,有说是gradle的*库下载的jar包有问题,后来我就到官网下载,地址是:http://poi.apache.org/download.html
我下载的是:poi-bin-3.16-20170419.zip,这个版本,下载完之后,把里面涉及的jar包都导入进去,发现问题依旧,后来我干脆就把其他的jar全删掉,只留下poi-3.16;poi-ooxml-schemas-3.16;poi-scratchpad-3.16这三个包。运行后发现,嘿,居然神奇的这个错误不报了,但同时出现了另外一个问题。

ProGuard, version 5.2.1
Reading program jar [E:\DoubleWork\NEWAPP\ols\build\intermediates\transforms\jarMerging\debug\jars\1\1f\combined.jar]
Reading library jar [D:\LocalSDK\AndroidStudio\sdk\build-tools\24.0.2\lib\shrinkedAndroid.jar]
Preparing output jar [E:\DoubleWork\NEWAPP\ols\build\intermediates\multi-dex\debug\componentClasses.jar]
  Copying resources from program jar [E:\DoubleWork\NEWAPP\ols\build\intermediates\transforms\jarMerging\debug\jars\1\1f\combined.jar]
:ols:transformClassesWithDexForDebug
To run dex in process, the Gradle daemon needs a larger heap.
It currently has approximately 910 MB.
For faster builds, increase the maximum heap size for the Gradle daemon to more than 2048 MB.
To do this set org.gradle.jvmargs=-Xmx2048M in the project gradle.properties.
For more information see https://docs.gradle.org/current/userguide/build_environment.html
Error:UNEXPECTED TOP-LEVEL ERROR:
Error:java.lang.OutOfMemoryError: GC overhead limit exceeded
:ols:transformClassesWithDexForDebug FAILED
Error:Execution failed for task ':ols:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_101\bin\java.exe'' finished with non-zero exit value 3

这个问题的关键一句在这

Error:java.lang.OutOfMemoryError: GC overhead limit exceeded

意思很明显,就是内存不足。加内存呗,在Androidstudio的gradle中配置

android {
...
     dexOptions {
        preDexLibraries false
        incremental false
        javaMaxHeapSize "3072m"
     }
...
}

最后运行,问题解决。
这个问题搞得真有点莫名其妙

相关标签: word