Android 项目的顶级异常

TOP LEVEL EXCEPTION on Android Project

我正在尝试构建我的 android 项目。该项目使用来自另一个项目 (API) 的方法,其中包含 属性 JAXB 方法来编组和解组。我在我的 android 项目中将项目 api 添加为带有 jersey 和 gson 库的 .jar,它始终显示 "Conversion to Dalvik format failed"。 这是日志:

[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.access0(Main.java:83)
at com.android.dx.command.dexer.Main.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.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.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.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-

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)。单击确定。转到项目 » 清理 » 清理项目 select 在下方 » select 您的项目,然后单击确定。应该可以。

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- 从构建路径中删除所有导入。 2- 手动将所有 .jar 文件复制到 /libs 目录中。 3- 从 /libs 中删除所有 jaxrs.jars。 4- 刷新项目。 5- 运行 项目。 6- 享受吧!

评论新问题。 :(