Android 工程成功编译后安装时报如下错误:
[2012-09-20 13:50:12 - Nems3.0-6] Dx
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/neusoft/widgetinstall/Const;
[2012-09-20 13:50:12 - Nems3.0-6] Dx at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at com.android.dx.command.dexer.Main.processClass(Main.java:486)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at com.android.dx.command.dexer.Main.access$400(Main.java:67)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at com.android.dx.command.dexer.Main.processOne(Main.java:418)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at com.android.dx.command.dexer.Main.run(Main.java:206)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at sun.reflect.GeneratedMethodAccessor21.invoke(Unknown Source)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at java.lang.reflect.Method.invoke(Unknown Source)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at com.android.ide.eclipse.adt.internal.build.DexWrapper.run(DexWrapper.java:180)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(BuildHelper.java:702)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build
(PostCompilerBuilder.java:646)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:629)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:172)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:282)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:363)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at org.eclipse.core.internal.resources.Project$1.run(Project.java:545)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:524)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at org.eclipse.core.internal.resources.Project.build(Project.java:123)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at com.android.ide.eclipse.adt.internal.project.ProjectHelper.doFullIncrementalDebugBuild
(ProjectHelper.java:1000)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at com.android.ide.eclipse.adt.internal.launch.LaunchConfigDelegate.launch
(LaunchConfigDelegate.java:147)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at org.eclipse.debug.internal.core.LaunchConfiguration.launch
(LaunchConfiguration.java:853)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at org.eclipse.debug.internal.core.LaunchConfiguration.launch
(LaunchConfiguration.java:702)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:924)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1128)
[2012-09-20 13:50:12 - Nems3.0-6] Dx at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
[2012-09-20 13:50:13 - Nems3.0-6] Dx 1 error; aborting
[2012-09-20 13:50:13 - Nems3.0-6] Conversion to Dalvik format failed with error 1
引起此错误的一个原因是工程中的 jar 包,着重看报错信息的第3行:
“java.lang.IllegalArgumentException: already added: Lcom/neusoft/widgetinstall/Const;”
由上述信息可知,问题是由 名为 widgetinstall 的这个 jar 包引起的。可以在工程的 libs 目录中找到该 jar
包,然后将其删除即可。