转换为 Dalvik 格式失败,错误 1 - 更新 Android SDK 后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
After updating SDK and ADT for the latest release, I tried to run my application and Eclipse log the following error:
[- 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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
我在更新到 2011 年 10 月的 ADT 和 SDK r15 版本后遇到了这个问题。我的项目使用3个项目作为库,因此项目之间存在很多相互依赖关系。当构建工具看到同一对象被多次定义时,就会出现此错误(我相信)。我的猜测是谷歌改变了库引用的工作方式,所以我旧的项目设置不再有效。
我尝试弄乱项目的库和构建路径设置,但无法使构建稳定。我想出的解决方案是:
在新工作区中设置库依赖项后,一切都编译得很好。我有很多设置不想丢失,所以我将重新生成的 .project 和 .classpath 文件复制回我原来的工作区,到目前为止它对我来说一直工作正常。
I ran into this issue after updating to the October 2011 r15 version of ADT and SDK. My project uses 3 projects as libraries, so there is a lot of interdependence between the projects. This error comes up (I believe) when the build tool sees the same object get defined multiple times. My guess is Google changed up how the library references work, so my old project setup was no longer valid.
I tried messing with the project's library and build path settings, but I couldn't get the build to be stable. The solution I came up with was to:
After I set up the library dependencies in the new workspace, everything compiled just fine. I had a lot of settings I didn't want to lose, so I copied the regenerated .project and .classpath files back into my original workspace and it has been working alright for me so far.
我认为你应该做清理项目并重建它,为我解决它。
I think you should do Clean Project and rebuild it, solved it for me.
解决办法是:
1)删除项目(不要从磁盘删除项目内容)。
2) 删除项目中的
.project
和.classpath
文件。3)使用当前src创建新项目(
从现有源创建项目
)The solution is:
1) Delete the project (do no delete project contents from disk).
2) Delete the
.project
and.classpath
files in the project.3) Create new project with the current src (
Create project from existing source
)如果在导出过程中发生这种情况,请删除项目 bin 目录中存在的文件。并重新启动导出。不到30秒就解决了
If this happens during export, delete files present in the bin directory of your project. and restart export. in less than 30 seconds is resolved
转到项目->属性 - > Java构建路径 - >库并删除除“Android XY”(在我的例子中为Android 5.0.1)之外的所有内容,您可以保留android依赖项(如果它不包含任何冲突的jar文件)。对订单和导出执行相同的操作(在项目 -> 属性 -> Java 构建路径 -> 订单和导出中)。单击“确定”。清理项目。它应该可以解决问题。
这是由于jar冲突问题引起的。
Go to Project-> Properties->Java Build Path->Libraries and remove all except the "Android X.Y" (in my case Android 5.0.1), You can keep android dependencies(if it doesn't contains any conflicting jar files). Do the same for order and export (in Project-> Properties->Java Build Path-> Order and export). Click OK. Clean the project. It should solve the problem.
It is caused due to jar conflicting issues.
尝试 android 更新项目
当您使用工作区中的某些库时,也许您必须删除在 Project -> 中将行链接到它们属性-> Java构建路径->来源
try android update project
when you use some libs from workspace maybe you must remove link-rows to they in Project -> Properties -> Java build path -> Source
我在 bin/dexedlibs 中打开了一个 cmd 窗口,当我 cd 到父级(bin)时,这为我解决了问题。所以这似乎是非常微妙的构建错误。在清理期间,构建器将删除 dexedlib 文件夹,并且可能在 rmdir 期间出现错误也会导致此失败。
I had a cmd window open in the bin/dexedlibs and when i cd to the parent (bin), that solved the problem for me. So it appears to be very subtle build errors. During a clean, the builder will remove the dexedlib folder, and perhaps that it gets an error during the rmdir will cause this failure also.
不需要创建新项目。
只需删除 gen 和 bin 文件夹并按项目清理即可。
Creating a new project is not necessary.
Just delete the gen and bin folder and press project clean.