转换为Dalvik格式失败,错误1 - 更新Android SDK& ADT

时间:2011-11-14 16:51:28

标签: android eclipse-adt

为最新版本更新SDK和ADT后,我尝试运行我的应用程序并且Eclipse记录以下错误:

[- RichReaderDemo] Dx 
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lbr/com/digitalpages/renderer/NewReaderActivity;
[- RichReaderDemo] Dx   at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[- RichReaderDemo] Dx   at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
[- RichReaderDemo] Dx   at com.android.dx.command.dexer.Main.processClass(Main.java:486)
[- RichReaderDemo] Dx   at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
[- RichReaderDemo] Dx   at com.android.dx.command.dexer.Main.access$400(Main.java:67)
[- RichReaderDemo] Dx   at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
[- RichReaderDemo] Dx   at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
[- RichReaderDemo] Dx   at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
[- RichReaderDemo] Dx   at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
[- RichReaderDemo] Dx   at com.android.dx.command.dexer.Main.processOne(Main.java:418)
[- RichReaderDemo] Dx   at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
[- RichReaderDemo] Dx   at com.android.dx.command.dexer.Main.run(Main.java:206)
[- RichReaderDemo] Dx   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[- RichReaderDemo] Dx   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[- RichReaderDemo] Dx   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[- RichReaderDemo] Dx   at java.lang.reflect.Method.invoke(Method.java:616)
[- RichReaderDemo] Dx   at com.android.ide.eclipse.adt.internal.build.DexWrapper.run(DexWrapper.java:179)
[- RichReaderDemo] Dx   at com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(BuildHelper.java:729)
[- RichReaderDemo] Dx   at com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build(PostCompilerBuilder.java:602)
[- RichReaderDemo] Dx   at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:629)
[- RichReaderDemo] Dx   at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
[- RichReaderDemo] Dx   at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:172)
[- RichReaderDemo] Dx   at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:282)
[- RichReaderDemo] Dx   at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:363)
[- RichReaderDemo] Dx   at org.eclipse.core.internal.resources.Project$1.run(Project.java:545)
[- RichReaderDemo] Dx   at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975)
[- RichReaderDemo] Dx   at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:524)
[- RichReaderDemo] Dx   at org.eclipse.core.internal.resources.Project.build(Project.java:123)
[- RichReaderDemo] Dx   at com.android.ide.eclipse.adt.internal.project.ProjectHelper.build(ProjectHelper.java:869)
[- RichReaderDemo] Dx   at com.android.ide.eclipse.adt.internal.launch.LaunchConfigDelegate.launch(LaunchConfigDelegate.java:146)
[- RichReaderDemo] Dx   at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:853)
[- RichReaderDemo] Dx   at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:702)
[- RichReaderDemo] Dx   at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:923)
[- RichReaderDemo] Dx   at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1126)
[- RichReaderDemo] Dx   at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
[- RichReaderDemo] Dx 
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lbr/com/digitalpages/commons/activity/LoadingActivity;
[- RichReaderDemo] Dx   at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[- RichReaderDemo] Dx   at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
[- RichReaderDemo] Dx   at com.android.dx.command.dexer.Main.processClass(Main.java:486)
[- RichReaderDemo] Dx   at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
[- RichReaderDemo] Dx   at com.android.dx.command.dexer.Main.access$400(Main.java:67)
[- RichReaderDemo] Dx   at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
[- RichReaderDemo] Dx   at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
[- RichReaderDemo] Dx   at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
[- RichReaderDemo] Dx   at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
[- RichReaderDemo] Dx   at com.android.dx.command.dexer.Main.processOne(Main.java:418)
[- RichReaderDemo] Dx   at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
[- RichReaderDemo] Dx   at com.android.dx.command.dexer.Main.run(Main.java:206)
[- RichReaderDemo] Dx   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[- RichReaderDemo] Dx   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
[- RichReaderDemo] Dx   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[- RichReaderDemo] Dx   at java.lang.reflect.Method.invoke(Method.java:616)
[- RichReaderDemo] Dx   at com.android.ide.eclipse.adt.internal.build.DexWrapper.run(DexWrapper.java:179)
[- RichReaderDemo] Dx   at com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(BuildHelper.java:729)
[- RichReaderDemo] Dx   at com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build(PostCompilerBuilder.java:602)
[- RichReaderDemo] Dx   at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:629)
[- RichReaderDemo] Dx   at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
[- RichReaderDemo] Dx   at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:172)
[- RichReaderDemo] Dx   at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:282)
[- RichReaderDemo] Dx   at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:363)
[- RichReaderDemo] Dx   at org.eclipse.core.internal.resources.Project$1.run(Project.java:545)
[- RichReaderDemo] Dx   at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975)
[- RichReaderDemo] Dx   at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:524)
[- RichReaderDemo] Dx   at org.eclipse.core.internal.resources.Project.build(Project.java:123)
[- RichReaderDemo] Dx   at com.android.ide.eclipse.adt.internal.project.ProjectHelper.build(ProjectHelper.java:869)
[- RichReaderDemo] Dx   at com.android.ide.eclipse.adt.internal.launch.LaunchConfigDelegate.launch(LaunchConfigDelegate.java:146)
[- RichReaderDemo] Dx   at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:853)
[- RichReaderDemo] Dx   at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:702)
[- RichReaderDemo] Dx   at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:923)
[- RichReaderDemo] Dx   at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1126)
[- RichReaderDemo] Dx   at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
[- RichReaderDemo] Dx 2 errors; aborting
[- RichReaderDemo] Conversion to Dalvik format failed with error 1

8 个答案:

答案 0 :(得分:12)

我在更新到2011年10月的ADT和SDK的r15版本后遇到了这个问题。我的项目使用3个项目作为库,因此项目之间存在很多相互依赖关系。当构建工具看到多次定义同一个对象时,会出现此错误(我相信)。我的猜测是Google更改了库引用的工作方式,因此我的旧项目设置不再有效。

我尝试搞乱项目的库并构建路径设置,但我无法使构建稳定。我提出的解决方案是:

  1. 关闭Eclipse
  2. 制作工作区的备份副本
  3. 删除每个项目中的.project和.classpath文件
  4. 在Eclipse中打开一个新工作区
  5. 使用 New Android Project 向导重新添加项目(选择“从现有源创建项目”)。注意:这与导入现有项目不同。
  6. 在新工作区中设置库依赖项之后,所有编译都很好。我有很多我不想丢失的设置,所以我将重新生成的.project和.classpath文件复制回原来的工作区,到目前为止它一直对我有用。

答案 1 :(得分:4)

我认为你应该做清洁项目并重建它,为我解决它。

答案 2 :(得分:2)

解决方案是:

1)删除项目(不要从磁盘中删除项目内容) 2)删除项目中的.project.classpath文件 3)使用当前的src(Create project from existing source

创建新项目

答案 3 :(得分:2)

如果在导出期间发生这种情况,请删除项目bin目录中的文件。并重新启动导出。在不到30秒的时间内解决了

答案 4 :(得分:1)

转到项目 - >属性 - > Java Build Path->库并删除除“Android X.Y”之外的所有内容(在我的案例中为Android 5.0.1),您可以保留android依赖项(如果它不包含任何冲突的jar文件)。对订单和导出执行相同操作(在Project-> Properties-> Java Build Path-> Order and export)。单击确定。清理项目。它应该解决问题。 这是由于jar冲突问题引起的。

答案 5 :(得分:0)

尝试android update project

当您从工作区使用某些库时,您可能必须在Project中删除链接行 - >属性 - > Java构建路径 - >源

答案 6 :(得分:0)

我在bin / dexedlibs中打开了一个cmd窗口,当我cd到父(bin)时,这解决了我的问题。所以它似乎是非常微妙的构建错误。在清理过程中,构建器将删除dexedlib文件夹,并且可能在rmdir期间出现错误也会导致此失败。

答案 7 :(得分:0)

无需创建新项目。

只需删除gen和bin文件夹,然后按清除项目。