java.lang.NoClassDefFoundError:org.apache.batik.dom.svg.SVGDOMImplementation

时间:2014-03-17 19:29:32

标签: java android libgdx dalvik batik

我在与我的Android& LibGDX项目链接的Apache Batik库中遇到了奇怪的麻烦。

但是让我们从一开始就开始,在IntelliJ Idea中我有一个包含三个模块的项目:Main,Android和Desktop。

enter image description here

"蜡染"我突出显示的图书馆包含:

enter image description here

" Main"中有一些代码。在Android和桌面模块中使用的模块:

    String parser = XMLResourceDescriptor.getXMLParserClassName();
    SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(parser);

以下代码用于获取SVG文档的宽度和高度,但调用SAXSVGDocumentFactory的构造函数仅在Android上引发异常。桌面版没有问题,没有任何问题:

03-17 18:23:46.928: ERROR/AndroidRuntime(1517): FATAL EXCEPTION: GLThread 17
        java.lang.NoClassDefFoundError: org.apache.batik.dom.svg.SVGDOMImplementation
        at org.apache.batik.dom.svg.SAXSVGDocumentFactory.<init>(SAXSVGDocumentFactory.java:111)
        at com.revicostudio.gra.GraRenderer.getDocumentWidthAndHeight(GraRenderer.java:103)
        at com.revicostudio.gra.GraRenderer.renderSvgToTexture(GraRenderer.java:66)
        at com.revicostudio.gra.GraRenderer.render(GraRenderer.java:59)
        at com.revicostudio.gra.GraScreen.render(GraScreen.java:31)
        at com.badlogic.gdx.Game.render(Game.java:46)
        at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(AndroidGraphics.java:499)
        at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1462)
        at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1216)

在dalvik发送的logcat中还有很多消息与org.apache.batik.dom。*类有关,据我所知,这些消息包含在batik-svg-dom.jar中:

03-17 20:26:37.688: INFO/dalvikvm(3632): Failed resolving Lorg/apache/batik/dom/ExtensibleDOMImplementation; interface 5043 'Lorg/w3c/dom/css/DOMImplementationCSS;'
03-17 20:26:37.688: WARN/dalvikvm(3632): Link of class 'Lorg/apache/batik/dom/ExtensibleDOMImplementation;' failed
03-17 20:26:37.688: WARN/dalvikvm(3632): Unable to resolve superclass of Lorg/apache/batik/dom/svg/SVGDOMImplementation; (2490)
03-17 20:26:37.688: WARN/dalvikvm(3632): Link of class 'Lorg/apache/batik/dom/svg/SVGDOMImplementation;' failed
03-17 20:26:37.688: INFO/dalvikvm(3632): Could not find method org.apache.batik.dom.svg.SVGDOMImplementation.getDOMImplementation, referenced from method org.apache.batik.dom.svg.SAXSVGDocumentFactory.<init>
03-17 20:26:37.688: WARN/dalvikvm(3632): VFY: unable to resolve static method 21646: Lorg/apache/batik/dom/svg/SVGDOMImplementation;.getDOMImplementation ()Lorg/w3c/dom/DOMImplementation;
03-17 20:26:37.688: DEBUG/dalvikvm(3632): VFY: replacing opcode 0x71 at 0x0000
03-17 20:26:37.688: INFO/dalvikvm(3632): Failed resolving Lorg/apache/batik/dom/ExtensibleDOMImplementation; interface 5043 'Lorg/w3c/dom/css/DOMImplementationCSS;'
03-17 20:26:37.688: WARN/dalvikvm(3632): Link of class 'Lorg/apache/batik/dom/ExtensibleDOMImplementation;' failed
03-17 20:26:37.688: WARN/dalvikvm(3632): Unable to resolve superclass of Lorg/apache/batik/dom/svg/SVGDOMImplementation; (2490)
03-17 20:26:37.688: WARN/dalvikvm(3632): Link of class 'Lorg/apache/batik/dom/svg/SVGDOMImplementation;' failed
03-17 20:26:37.688: INFO/dalvikvm(3632): Could not find method org.apache.batik.dom.svg.SVGDOMImplementation.getDOMImplementation, referenced from method org.apache.batik.dom.svg.SAXSVGDocumentFactory.<init>
03-17 20:26:37.688: WARN/dalvikvm(3632): VFY: unable to resolve static method 21646: Lorg/apache/batik/dom/svg/SVGDOMImplementation;.getDOMImplementation ()Lorg/w3c/dom/DOMImplementation;
03-17 20:26:37.688: DEBUG/dalvikvm(3632): VFY: replacing opcode 0x71 at 0x0000
03-17 20:26:37.698: INFO/dalvikvm(3632): Failed resolving Lorg/apache/batik/dom/AbstractDocument; interface 5227 'Lorg/w3c/dom/traversal/DocumentTraversal;'
03-17 20:26:37.698: WARN/dalvikvm(3632): Link of class 'Lorg/apache/batik/dom/AbstractDocument;' failed
03-17 20:26:37.698: WARN/dalvikvm(3632): Unable to resolve superclass of Lorg/apache/batik/dom/AbstractStylableDocument; (2467)
03-17 20:26:37.698: WARN/dalvikvm(3632): Link of class 'Lorg/apache/batik/dom/AbstractStylableDocument;' failed
03-17 20:26:37.698: WARN/dalvikvm(3632): Unable to resolve superclass of Lorg/apache/batik/dom/svg/SVGOMDocument; (2485)
03-17 20:26:37.698: WARN/dalvikvm(3632): Link of class 'Lorg/apache/batik/dom/svg/SVGOMDocument;' failed
03-17 20:26:37.698: ERROR/dalvikvm(3632): Could not find class 'org.apache.batik.dom.svg.SVGOMDocument', referenced from method org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument
03-17 20:26:37.698: WARN/dalvikvm(3632): VFY: unable to resolve check-cast 2746 (Lorg/apache/batik/dom/svg/SVGOMDocument;) in Lorg/apache/batik/dom/svg/SAXSVGDocumentFactory;
03-17 20:26:37.698: DEBUG/dalvikvm(3632): VFY: replacing opcode 0x1f at 0x0062
03-17 20:26:37.698: INFO/dalvikvm(3632): Failed resolving Lorg/apache/batik/dom/AbstractDocument; interface 5227 'Lorg/w3c/dom/traversal/DocumentTraversal;'
03-17 20:26:37.698: WARN/dalvikvm(3632): Link of class 'Lorg/apache/batik/dom/AbstractDocument;' failed
03-17 20:26:37.698: WARN/dalvikvm(3632): Unable to resolve superclass of Lorg/apache/batik/dom/AbstractStylableDocument; (2467)
03-17 20:26:37.698: WARN/dalvikvm(3632): Link of class 'Lorg/apache/batik/dom/AbstractStylableDocument;' failed
03-17 20:26:37.698: WARN/dalvikvm(3632): Unable to resolve superclass of Lorg/apache/batik/dom/svg/SVGOMDocument; (2485)
03-17 20:26:37.698: WARN/dalvikvm(3632): Link of class 'Lorg/apache/batik/dom/svg/SVGOMDocument;' failed
03-17 20:26:37.698: ERROR/dalvikvm(3632): Could not find class 'org.apache.batik.dom.svg.SVGOMDocument', referenced from method org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument
03-17 20:26:37.698: WARN/dalvikvm(3632): VFY: unable to resolve check-cast 2746 (Lorg/apache/batik/dom/svg/SVGOMDocument;) in Lorg/apache/batik/dom/svg/SAXSVGDocumentFactory;
03-17 20:26:37.698: DEBUG/dalvikvm(3632): VFY: replacing opcode 0x1f at 0x0013
03-17 20:26:37.698: INFO/dalvikvm(3632): Failed resolving Lorg/apache/batik/dom/AbstractDocument; interface 5227 'Lorg/w3c/dom/traversal/DocumentTraversal;'
03-17 20:26:37.698: WARN/dalvikvm(3632): Link of class 'Lorg/apache/batik/dom/AbstractDocument;' failed
03-17 20:26:37.698: ERROR/dalvikvm(3632): Could not find class 'org.apache.batik.dom.AbstractDocument', referenced from method org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument
03-17 20:26:37.698: WARN/dalvikvm(3632): VFY: unable to resolve check-cast 2467 (Lorg/apache/batik/dom/AbstractDocument;) in Lorg/apache/batik/dom/svg/SAXSVGDocumentFactory;
03-17 20:26:37.698: DEBUG/dalvikvm(3632): VFY: replacing opcode 0x1f at 0x001f
03-17 20:26:37.698: INFO/dalvikvm(3632): Failed resolving Lorg/apache/batik/dom/AbstractDocument; interface 5227 'Lorg/w3c/dom/traversal/DocumentTraversal;'
03-17 20:26:37.698: WARN/dalvikvm(3632): Link of class 'Lorg/apache/batik/dom/AbstractDocument;' failed
03-17 20:26:37.698: WARN/dalvikvm(3632): Unable to resolve superclass of Lorg/apache/batik/dom/AbstractStylableDocument; (2467)
03-17 20:26:37.698: WARN/dalvikvm(3632): Link of class 'Lorg/apache/batik/dom/AbstractStylableDocument;' failed
03-17 20:26:37.698: WARN/dalvikvm(3632): Unable to resolve superclass of Lorg/apache/batik/dom/svg/SVGOMDocument; (2485)
03-17 20:26:37.698: WARN/dalvikvm(3632): Link of class 'Lorg/apache/batik/dom/svg/SVGOMDocument;' failed
03-17 20:26:37.698: ERROR/dalvikvm(3632): Could not find class 'org.apache.batik.dom.svg.SVGOMDocument', referenced from method org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument
03-17 20:26:37.698: WARN/dalvikvm(3632): VFY: unable to resolve check-cast 2746 (Lorg/apache/batik/dom/svg/SVGOMDocument;) in Lorg/apache/batik/dom/svg/SAXSVGDocumentFactory;
03-17 20:26:37.698: DEBUG/dalvikvm(3632): VFY: replacing opcode 0x1f at 0x0013
03-17 20:26:37.698: INFO/dalvikvm(3632): Failed resolving Lorg/apache/batik/dom/AbstractDocument; interface 5227 'Lorg/w3c/dom/traversal/DocumentTraversal;'
03-17 20:26:37.698: WARN/dalvikvm(3632): Link of class 'Lorg/apache/batik/dom/AbstractDocument;' failed
03-17 20:26:37.698: ERROR/dalvikvm(3632): Could not find class 'org.apache.batik.dom.AbstractDocument', referenced from method org.apache.batik.dom.svg.SAXSVGDocumentFactory.createDocument
03-17 20:26:37.698: WARN/dalvikvm(3632): VFY: unable to resolve check-cast 2467 (Lorg/apache/batik/dom/AbstractDocument;) in Lorg/apache/batik/dom/svg/SAXSVGDocumentFactory;
03-17 20:26:37.698: DEBUG/dalvikvm(3632): VFY: replacing opcode 0x1f at 0x001f
03-17 20:26:37.698: INFO/dalvikvm(3632): Failed resolving Lorg/apache/batik/dom/ExtensibleDOMImplementation; interface 5043 'Lorg/w3c/dom/css/DOMImplementationCSS;'
03-17 20:26:37.698: WARN/dalvikvm(3632): Link of class 'Lorg/apache/batik/dom/ExtensibleDOMImplementation;' failed
03-17 20:26:37.698: WARN/dalvikvm(3632): Unable to resolve superclass of Lorg/apache/batik/dom/svg/SVGDOMImplementation; (2490)
03-17 20:26:37.698: WARN/dalvikvm(3632): Link of class 'Lorg/apache/batik/dom/svg/SVGDOMImplementation;' failed
03-17 20:26:37.698: INFO/dalvikvm(3632): Could not find method org.apache.batik.dom.svg.SVGDOMImplementation.getDOMImplementation, referenced from method org.apache.batik.dom.svg.SAXSVGDocumentFactory.getDOMImplementation
03-17 20:26:37.698: WARN/dalvikvm(3632): VFY: unable to resolve static method 21646: Lorg/apache/batik/dom/svg/SVGDOMImplementation;.getDOMImplementation ()Lorg/w3c/dom/DOMImplementation;
03-17 20:26:37.698: DEBUG/dalvikvm(3632): VFY: replacing opcode 0x71 at 0x0018
03-17 20:26:37.698: INFO/dalvikvm(3632): Failed resolving Lorg/apache/batik/dom/ExtensibleDOMImplementation; interface 5043 'Lorg/w3c/dom/css/DOMImplementationCSS;'
03-17 20:26:37.698: WARN/dalvikvm(3632): Link of class 'Lorg/apache/batik/dom/ExtensibleDOMImplementation;' failed
03-17 20:26:37.698: WARN/dalvikvm(3632): Unable to resolve superclass of Lorg/apache/batik/dom/svg/SVGDOMImplementation; (2490)
03-17 20:26:37.698: WARN/dalvikvm(3632): Link of class 'Lorg/apache/batik/dom/svg/SVGDOMImplementation;' failed
03-17 20:26:37.698: WARN/dalvikvm(3632): Unable to resolve superclass of Lorg/apache/batik/dom/svg12/SVG12DOMImplementation; (2676)
03-17 20:26:37.698: WARN/dalvikvm(3632): Link of class 'Lorg/apache/batik/dom/svg12/SVG12DOMImplementation;' failed
03-17 20:26:37.698: INFO/dalvikvm(3632): Could not find method org.apache.batik.dom.svg12.SVG12DOMImplementation.getDOMImplementation, referenced from method org.apache.batik.dom.svg.SAXSVGDocumentFactory.getDOMImplementation
03-17 20:26:37.698: WARN/dalvikvm(3632): VFY: unable to resolve static method 23668: Lorg/apache/batik/dom/svg12/SVG12DOMImplementation;.getDOMImplementation ()Lorg/w3c/dom/DOMImplementation;
03-17 20:26:37.698: DEBUG/dalvikvm(3632): VFY: replacing opcode 0x71 at 0x0025
03-17 20:26:37.728: WARN/dalvikvm(3632): threadid=10: thread exiting with uncaught exception (group=0x313c61f8)

另外,make上有很多警告: enter image description here

导致此问题的原因是什么?

1 个答案:

答案 0 :(得分:2)

Batik使用Java2D API,这在Android上无法使用。您需要使用另一个库。