我在我的android项目中使用xalan.jar。当我构建项目时->错误(我在properties/java构建路径/Order和Export/xalan.jar中进行了选择)。 (如果没有,则在“Order and Export/xalan.jar”项目构建中选择xalan.jar。)

控制台中的详细信息错误:

[2013-12-30 15:20:28 - SignAndroid] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.xml.serializer.CharInfo$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
[2013-12-30 15:20:28 - SignAndroid] Dx
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: bad utf-8 byte 9a at offset 00000002
    at com.android.dx.cf.cst.ConstantPoolParser.parseUtf8(ConstantPoolParser.java:374)
    at com.android.dx.cf.cst.ConstantPoolParser.parse0(ConstantPoolParser.java:262)
    at com.android.dx.cf.cst.ConstantPoolParser.parse0(ConstantPoolParser.java:294)
    at com.android.dx.cf.cst.ConstantPoolParser.parse(ConstantPoolParser.java:150)
    at com.android.dx.cf.cst.ConstantPoolParser.parseIfNecessary(ConstantPoolParser.java:124)
    at com.android.dx.cf.cst.ConstantPoolParser.getPool(ConstantPoolParser.java:115)
    at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:482)
    at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
    at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
    at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
    at com.android.dx.command.dexer.Main.processClass(Main.java:665)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
    at com.android.dx.command.dexer.Main.access$600(Main.java:78)
    at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
    at com.android.dx.command.dexer.Main.processOne(Main.java:596)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
    at com.android.dx.command.dexer.Main.run(Main.java:230)
    at sun.reflect.GeneratedMethodAccessor71.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at com.android.ide.eclipse.adt.internal.build.DexWrapper.run(DexWrapper.java:187)
    at com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(BuildHelper.java:753)
    at com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build(PostCompilerBuilder.java:593)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:726)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:321)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:396)
    at org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
    at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
    at org.eclipse.core.internal.resources.Project.build(Project.java:124)
    at com.android.ide.eclipse.adt.internal.project.ProjectHelper.doFullIncrementalDebugBuild(ProjectHelper.java:1116)
    at com.android.ide.eclipse.adt.internal.launch.LaunchConfigDelegate.launch(LaunchConfigDelegate.java:147)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:855)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:704)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1047)
    at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1251)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: java.lang.IllegalArgumentException: bad utf-8 byte 9a at offset 00000002
    at com.android.dx.rop.cst.CstString.throwBadUtf8(CstString.java:171)
    at com.android.dx.rop.cst.CstString.utf8BytesToString(CstString.java:143)
    at com.android.dx.rop.cst.CstString.<init>(CstString.java:200)
    at com.android.dx.cf.cst.ConstantPoolParser.parseUtf8(ConstantPoolParser.java:371)
    ... 42 more
...while parsing cst 004f at offset 00000205
...while parsing cst 0005 at offset 00000018
...while parsing org/apache/xml/serializer/utils/SerializerMessages_ru.class

[2013-12-30 15:20:28 - SignAndroid] Dx 1 error; aborting
[2013-12-30 15:20:28 - SignAndroid] Conversion to Dalvik format failed with error 1

最佳答案

我很晚才知道,但是如果您还没有任何解决方法,那么这是对我有用的解决方案。我正在使用xalan 2.7.1 jar,并将其升级到2.7.2,可以从此处下载:

http://psg.mtu.edu/pub/apache/xalan/xalan-j/binaries/

另外,用xalan-2.7.2附带的序列化器jar替换您的“serializer.jar”。之后,只需清理您的项目并运行它即可。

关于java - 在Android项目中构建时出现Xalan.jar错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20836047/

10-11 10:38