0

我正在尝试从 xmlbeans-2.6.0.jar 和 xmlbeans-2.3.0.jar 构建 dex 文件。我收到以下错误

[2013-02-14 14:57:08 - SOSTestProject] Dx warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.apache.xmlbeans.impl.store.Locale$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-02-14 14:57:08 - SOSTestProject] Dx 
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lorg/apache/xmlbeans/xml/stream/Location;
[2013-02-14 14:57:08 - SOSTestProject] Dx   at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at com.android.dx.command.dexer.Main.processClass(Main.java:490)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at com.android.dx.command.dexer.Main.processFileBytes(Main.java:459)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at com.android.dx.command.dexer.Main.access$400(Main.java:67)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:398)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at com.android.dx.command.dexer.Main.processOne(Main.java:422)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at com.android.dx.command.dexer.Main.processAllFiles(Main.java:333)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at com.android.dx.command.dexer.Main.run(Main.java:209)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at java.lang.reflect.Method.invoke(Unknown Source)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at com.android.ide.eclipse.adt.internal.build.DexWrapper.run(DexWrapper.java:187)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(BuildHelper.java:745)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build(PostCompilerBuilder.java:598)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:728)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:199)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:321)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:396)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2344)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at org.eclipse.core.internal.resources.Project.build(Project.java:124)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at com.android.ide.eclipse.adt.internal.project.ProjectHelper.doFullIncrementalDebugBuild(ProjectHelper.java:1046)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at com.android.ide.eclipse.adt.internal.launch.LaunchConfigDelegate.launch(LaunchConfigDelegate.java:147)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:855)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:704)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1047)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1251)
[2013-02-14 14:57:08 - SOSTestProject] Dx   at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
[2013-02-14 14:57:08 - SOSTestProject] Dx 1 error; aborting
[2013-02-14 14:57:08 - SOSTestProject] Conversion to Dalvik format failed with error 1

我认为 DVM 无法将匿名内部类转换为 .dex 格式。如果有人能对此提供帮助,那将非常有帮助。

4

1 回答 1

2

匿名内部类没有问题。正如警告所提到的,这几乎可以肯定是一种较旧的类文件格式,并且可能会忽略该警告。

该错误与正在添加到您尝试创建的 dex 文件的一组类中提到的类的多个副本有关。

根据您提供的稀疏信息,我猜您将 jar 的两个版本都放入了项目的 lib 目录。这是行不通的,因为一个 dex 文件不能包含一个类的多个副本(即 1.3 版本和 1.6 版本)。

如果您必须同时拥有这两个版本,则需要重命名其中一个库中的类。例如,您可以使用jarjar工具自动更改类的包名。

于 2013-02-14T18:45:31.240 回答