android studio 解析Excel数据格式导入poi-3.17.jar时的一系列报错及处理Failed resolution of: Ljavax/xml/stream/XMLEventFactory,duplicate entry: org/apache/xmlbeans/xml/stream/Location.class,GC overhead limit exceeded

在org官网下载的poi jar包,导入到studio

compile files('libs/poi-3.17.jar')

compile files('libs/poi-ooxml-3.17.jar')

compile files('libs/poi-ooxml-schemas-3.17.jar')

compile files('libs/xmlbeans-2.6.0.jar')

如果项目报

java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/xml/stream/XMLEventFactory;
Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.xml.stream.XMLEventFactory" on path: DexPathList[[zip file "/data/app/com.

可能是使用的jar包版本过高,我换成3.10的版本之后就好了。



再报异常

Error:Execution failed for task ':app:transformClassesWithJarMergingForDebug'.
> com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry:
org/apache/xmlbeans/xml/stream/Location.class

原因是最新的xmlbeans-2.6.0.jar中包含了重复的类文件,将jar包更换为稍低的版本就行了;

但是接着可能会报内存溢出异常,Error:java.lang.OutOfMemoryError: GC overhead limit exceeded

在Androidstudio的gradle中配置即可。

 

android {
...
     dexOptions {
        preDexLibraries false
        incremental false
        javaMaxHeapSize "3072m"
     }
...
}
原文地址:https://www.cnblogs.com/Sharley/p/8400157.html