gpt4 book ai didi

java - 将 jar 导入 android 项目时出错

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:16:31 24 4
gpt4 key购买 nike

将 apache xerces.jar 放入构建路径时出现以下错误 ..

我之前已经搜索过错误..并且描述的解决方案是针对冲突的 jars..但这里不是这种情况..由于错误的 utf-8,我得到了一些 ParserException

我试过了(但没有成功):

  • 清理项目
  • 重启 eclipse
  • 更新广告、SDK
  • 删除所有库并修复项目属性,然后导入努力解决冲突
  • 另外我只有 1 个外部库 xerces

来自 here 的解决方案

删除 xerces 运行项目

几个月前,我通过构建路径正常导入了 xerces,并且成功了。任何帮助表示赞赏!

[2013-12-24 12:21:44 - tryout] Dx UNEXPECTED TOP-LEVEL EXCEPTION: com.android.dx.cf.iface.ParseException: bad utf-8 byte a0 at offset 00000004 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.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.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:786) at com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build(PostCompilerBuilder.java:597) at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:733) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206) at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:328) at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:403) at org.eclipse.core.internal.resources.Project$1.run(Project.java:618) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2345) 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:858) at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:707) at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1018) at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1222) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53) Caused by: java.lang.IllegalArgumentException: bad utf-8 byte a0 at offset 00000004 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.(CstString.java:200) at com.android.dx.cf.cst.ConstantPoolParser.parseUtf8(ConstantPoolParser.java:371) ... 43 more ...while parsing cst 012c at offset 00000afe ...while parsing cst 00a5 at offset 00000316 ...while parsing > org/apache/xerces/impl/xpath/regex/ParserForXMLSchema.class

> [2013-12-24 12:21:44 - tryout] Dx 1 error; aborting [2013-12-24 12:21:44 - tryout] Conversion to Dalvik format failed with error 1

最佳答案

在你的问题中,你提到:

Few months ago i had imported xerces normally via build path and it had worked

这对我来说是个危险信号,因为对于不断更新的库来说,“几个月”可能就像一生一样。也许您的问题不是 jar 文件与 Eclipse 的兼容性,而是 jar 文件本身的问题,这可以用“错误的 UTF-8 字节”解释您的解析器错误。

根据 Apache ( http://xerces.apache.org/xerces2-j/install.html ),事实证明 xerces.jar 现在已被弃用:

xerces.jar is no longer available in the main distribution. You can still download this jar from deprecated distribution. xerces.jar is a Jar file that contains all the parser class files (i.e., it contains the intersection of the contents of xercesImpl.jar and xml-apis.jar).

因此,在上面列出的同一页面上,我发现您只需用两个新文件替换 xerces.jar:xercesImpl.jarxml-apis.jar .请参阅下面的摘录(来自与上面相同的链接):

Changes in Xerces jar files:

In order to accommodate the very common case in which Xerces is used with an XSLT processor such as Xalan, between Xerces 2.0.0 beta 3 and beta 4 a change in the default organization of Xerces' jar files was introduced. As well as the xercesSamples.jar file, which we still produce, Xerces formerly came with a file called xerces.jar. This file contained all of the parser's functionality. Two files are now included: xercesImpl.jar, our implementation of various APIs, and xml-apis.jar, the APIs themselves. This was done so that, if your XSLT processor ships with APIs at the same level as those supported by Xerces-J, you can avoid putting xml-apis.jar on your classpath.

如果您仍想/需要使用 xerces.jar,Apache 提供了一种向后兼容的方法:

Should you wish to use the xerces.jar instead, we have included several Ant targets for backward compatibility. An "Ant target" is an argument given to Ant, our build tool, that tells it which portions of the build.xml file to apply.

If you are on a Windows system and you wish to get only the xerces.jar file, you would execute build.bat deprecatedjars.

上面的链接继续列出您可能遇到的版本问题的更多潜在问题。如果这能解决您的问题,请告诉我;如果没有,我会继续寻找可能的解决方案。

关于java - 将 jar 导入 android 项目时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20756461/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com