2011-11-14 47 views
5

更新SDK和ADT爲最新版本後,我試圖運行我的應用程序和Eclipse記錄以下錯誤:轉換爲Dalvik的格式錯誤1失敗 - 更新的Android SDK和ADT

[- 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 

回答

12

我更新後,就遇到了這個問題到2011年10月的ADT和SDK的r15版本。我的項目使用3個項目作爲庫,所以項目之間有很多相互依賴關係。這個錯誤出現了(我相信)當構建工具看到同一個對象被多次定義時。我的猜測是谷歌改變了圖書館參考工作的方式,所以我舊的項目設置不再有效。

我試圖搞亂項目的庫和構建路徑設置,但我無法讓構建穩定。我想出瞭解決的辦法是:

  1. 關閉Eclipse
  2. 使工作區
  3. 刪除每個項目
  4. 在Eclipse中打開一個新的工作區。項目和classpath文件的備份副本
  5. 使用新建Android項目嚮導(選擇「從現有源創建項目」)重新添加項目。注意:這與導入現有項目不同。

當我在新的工作區中設置了庫依賴關係之後,編譯的所有東西都很好。我有很多我不想丟失的設置,因此我將重新生成的.project和.classpath文件複製回原始工作空間,至今爲止我一直在爲我工作。

+1

類似的方法也解決了我(創建一個新項目) –

+0

啊是的,你的評論是更簡潔:「創建一個新的項目」:) –

+0

救了我!謝謝! – marienke

4

我想你應該做Clean Project並重建它,爲我解決它。

0

嘗試android update project

當您使用從工作區的一些庫也許您必須刪除鏈接行,他們在項目 - >屬性 - > Java構建路徑 - >源

2

解決方法是:

1)刪除項目(不要從磁盤刪除項目內容)。
2)刪除項目中的.project.classpath文件。
3)創建與當前SRC(Create project from existing source

0

新的項目,我必須在bin/dexedlibs打開CMD窗口,當我cd到父(BIN),即解決了這個問題對我來說。所以它看起來是非常微妙的構建錯誤。在清理期間,構建器將刪除dexedlib文件夾,並且可能在rmdir期間出現錯誤也會導致此故障。

2

如果在導出過程中發生這種情況,請刪除項目bin目錄中的文件。並重新啓動導出。在不到30秒的時間內解決了

0

無需創建新項目。

只需刪除gen和bin文件夾,然後按項目清理。

1

轉到項目 - >屬性 - > Java構建路徑 - >庫,並刪除除「Android X.Y」(在我的情況下爲Android 5.0。1),你可以保持android依賴(如果它不包含任何衝突的jar文件)。對訂單和導出執行相同的操作(在Project-> Properties-> Java Build Path-> Order and export)。點擊確定。清理項目。它應該解決問題。 這是由於jar衝突問題引起的。

相關問題