的Xerces换的Andr​​oid的NoClassDefFoundError使用的jar包替换来源$ C ​​$ C的当 [英] Xerces-for-Android NoClassDefFoundError When Using Jar Instead of Source Code

查看:179
本文介绍了的Xerces换的Andr​​oid的NoClassDefFoundError使用的jar包替换来源$ C ​​$ C的当的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Xerces换Android平台/$c$c.google.com/p/xerces-for-android/

I'm working with Xerces-for-Android: https://code.google.com/p/xerces-for-android/

如果我复制源$ C ​​$ C成一个简单的测试项目(Java项目,而不是Android项目),我没有任何问题,运行我的XML验证测试。

If I copy the source code into a simple test project (java project, not android project), I can run my xml validator tests without any issues.

当我做一个罐子从源文件,然后使用,在我的类路径而不是源,我得到的NoClassDefFoundError 尽管是在present文件罐。

When I make a jar from the source files then use that in my class path instead of the source, I get NoClassDefFoundError despite the files being present in the jar.

以下是错误消息:

java.lang.ExceptionInInitializerError
    at mf.org.apache.xerces.impl.dv.SchemaDVFactory.getInstance(Unknown Source)
    at mf.org.apache.xerces.impl.dv.SchemaDVFactory.getInstance(Unknown Source)
    at mf.org.apache.xerces.impl.xs.XMLSchemaLoader.reset(Unknown Source)
    at mf.org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
    at mf.org.apache.xerces.impl.xs.XMLSchemaLoader.loadGrammar(Unknown Source)
    at mf.org.apache.xerces.jaxp.validation.XMLSchemaFactory.newSchema(Unknown Source)
    at mf.javax.xml.validation.SchemaFactory.newSchema(Unknown Source)
    at xml.MFXMLUtil.validate(MFXMLUtil.java:33)
    at xml.MFXMLTester.main(MFXMLTester.java:8)
Caused by: java.lang.RuntimeException: internal error
    at mf.org.apache.xerces.impl.dv.xs.XSSimpleTypeDecl.applyFacets1(Unknown Source)
    at mf.org.apache.xerces.impl.dv.xs.BaseSchemaDVFactory.createBuiltInTypes(Unknown Source)
    at mf.org.apache.xerces.impl.dv.xs.SchemaDVFactoryImpl.createBuiltInTypes(Unknown Source)
    at mf.org.apache.xerces.impl.dv.xs.SchemaDVFactoryImpl.<clinit>(Unknown Source)
    ... 9 more

下面是我的ant脚本,使罐:

Below is my ant script to make the jar:

<project name="XercesForAndroid" default="dist" basedir=".">
    <description>
        Builds jar for Xerces-For-Android
    </description>
  <!-- set global properties for this build -->
  <property name="src" location="src"/>
  <property name="build" location="build"/>
  <property name="dist"  location="dist"/>

  <target name="init">
    <!-- Create the build directory structure used by compile -->
    <mkdir dir="${build}"/>
  </target>

  <target name="compile" depends="clean, init" description="compile the source " >
    <!-- Compile the java code from ${src} into ${build} -->
    <javac verbose="true" target="1.6" srcdir="${src}" destdir="${build}"/>
  </target>

  <target name="dist" depends="compile"
        description="generate the distribution" >
    <!-- Create the distribution directory -->
    <mkdir dir="${dist}/lib"/>

    <!-- Put everything in ${build} into the .jar file -->
    <jar jarfile="${dist}/lib/Xerces-For-Android.jar" basedir="${build}"/>
  </target>

  <target name="clean"
        description="clean up" >
    <!-- Delete the ${build} and ${dist} directory trees -->
    <delete dir="${build}"/>
    <delete dir="${dist}"/>
  </target>
</project>

的类文件在罐子里存在。我需要做什么特别的表现,还是我失去了一些东西明显?

The class files exist in the jar. Do I need to do anything special in the manifest, or am I missing something obvious?

推荐答案

我在该项目的作者取得了联系。他们用日食导出的jar文件。我注意到在Eclipse导出的jar文件和我的蚂蚁jar文件之间的罐子尺寸大小差异。

I got in contact with the authors of the project. They used eclipse to export the jar file. I noticed a size difference in the jar size between the eclipse exported jar file and my ant jar file.

不是真的知道我在我的ant脚本(甚至试图 ** / * ,但没有prevail),但下面是详细失踪情况下任何人有同样的问题。

Not really sure what I was missing in my ant script (even tried **/*, but to no prevail), however below are the details in case anyone has the same issue.

File -> Export -> Java / JAR File -> Check "Export all output folders for checked projects"

下面的设置截图我用得到的jar正常工作:

Below is a screenshot of the settings I used to get the jar to work properly:

这篇关于的Xerces换的Andr​​oid的NoClassDefFoundError使用的jar包替换来源$ C ​​$ C的当的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆