0

I am trying to build dex file from xmlbeans-2.6.0.jar and xmlbeans-2.3.0.jar.I am getting following error

[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

I think DVM can't translate anonymous inner classes into .dex format.If anyone can help regarding this,it will be really helpful.

Samrat
  • 161
  • 2
  • 16
  • Are you adding both versions of the library to the lib folder in your project? – JesusFreke Feb 14 '13 at 18:46
  • @JesusFreke I could no find any jar added twice in my project build path or multiple classes with the same name.But I have a doubt whether android.jar itself contains some of the classes defined in xmlbeans.jar file.If it is so,should the conversion of xmlbeans.jar to dex format fail?(As I have experienced same error while trying to convert the xmlbeans.jar to dex format from command line.) Can you please confirm me this? – Samrat Feb 19 '13 at 07:33

1 Answers1

2

There is no issue with anonymous inner classes. As mentioned by the warning, this is almost certainly an older classfile format, and the warning can likely be ignored.

The error is related to there being multiple copies of the mentioned class in the set of classes that are being added to the dex file that you are trying to create.

Based on the sparse information you provided, I'm going to guess that you put both versions of the jar into your project's lib directory. This won't work, because a dex file cannot contain multiple copies of a class (i.e. the 1.3 version and the 1.6 version).

If you must have both versions, you will need to rename the classes in one of the libraries. For example, you can use the jarjar tool to automatically change the package names of the classes.

JesusFreke
  • 19,784
  • 5
  • 65
  • 68
  • Thanks for your suggestion. I have added only one version of xmlbeans.jar file in my project,which I have compiled from xmlbeans source code.I have converted all jar files separately in dex format using dx --dex --output="c:\temp\Myxml.apk" "c:\temp\xbean.jar".There it is showing the same error.So I think the problem is in xmlbeans jar file.It would be great if anyone can help me regarding this – Samrat Feb 18 '13 at 09:24