Android项目的最高级别例外

时间:2015-03-30 17:03:33

标签: android eclipse jaxb

我正在尝试构建我的android项目。该项目使用来自另一个项目(API)的方法,该项目包含用于编组和解组的属性JAXB方法。我在我的android项目中将项目api添加为带有jersey和gson库的.jar,它总是显示“转换为Dalvik格式失败”。 这是日志:

[2015-03-30 18:29:28 - HolaCampus] Dx 
UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: class name (com/theoryinpractise/halbuilder/jaxrs/HalUnmarshallerTest) does not match path (target/test-classes/com/theoryinpractise/halbuilder/jaxrs/HalUnmarshallerTest.class)
at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:520)
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:704)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:673)
at com.android.dx.command.dexer.Main.access$300(Main.java:83)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:602)
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:632)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:510)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:280)
at com.android.dx.command.dexer.Main.run(Main.java:246)
at sun.reflect.GeneratedMethodAccessor43.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.android.ide.eclipse.adt.internal.build.DexWrapper.run(DexWrapper.java:188)
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:734)
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:2313)
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:1143)
at com.android.ide.eclipse.adt.internal.launch.LaunchConfigDelegate.launch(LaunchConfigDelegate.java:155)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:885)
at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:739)
at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1039)
at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1256)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
...while parsing target/test-classes/com/theoryinpractise/halbuilder/jaxrs/HalUnmarshallerTest.class

[2015-03-30 18:29:28 - HolaCampus] Dx 1 error; aborting
[2015-03-30 18:29:28 - HolaCampus] Conversion to Dalvik format failed with error 1

我已经阅读了其他类似错误的帖子,我尝试了这个可能的解决方案而没有幸运: 1- https://stackoverflow.com/a/24230984/4230181

Right click to your project, select properties.
A dialog will show up, select 'Java build path' on the left menu.
Remove 'Android dependencies' and 'Android private libraries' on the right panel then click OK
Clean your project (select menu Project --> Clean)
Right click your project, select Android Tools -> Fix project properties
Clean project once again.
Restart your computer
Open eclipse and Export apk

2-转到项目»属性»Java构建路径»库并删除除“Android X.Y”之外的所有内容(在我的案例中为Android 1.5)。单击确定。转到项目»清洁»清除下面选择的项目»选择项目,然后单击确定。这应该有用。

3-在这种情况下,当我导出apk时,显示转换为dalvik时出现相同的错误。

Go to Project -> uncheck Build Automatically

Go to Project -> Clean... , clean both the library project and your app project

Export your app as a signed APK while Build Automatically is still disabled

您如何看待这个?我不知道我还能尝试什么。感谢

1 个答案:

答案 0 :(得分:0)

我解决了。解: 1-清除构建路径中的所有导入。 2-手动将所有.jar文件复制到/ libs目录。 3-清除/ libs中的所有jaxrs .jars。 4-刷新项目。 5-运行项目。 6-享受!

评论新问题。 :(