0

我在使用 Ant 构建包含 ActionBarSherlock 的项目时遇到问题。

实际上,编译过程中剩余的错误如下

-dex:
      [dex] Converting compiled files and external libraries into C:\ProjetsECLIPSE\SEMobile_BP\bin\classes.dex...
       [dx] 
       [dx] UNEXPECTED TOP-LEVEL EXCEPTION:
       [dx] java.lang.IllegalArgumentException: already added: Landroid/support/v4/app/Watson$OnCreateOptionsMenuListener;
       [dx]     at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
       [dx]     at com.android.dx.dex.file.DexFile.add(DexFile.java:163)
       [dx]     at com.android.dx.command.dexer.Main.processClass(Main.java:486)
       [dx]     at com.android.dx.command.dexer.Main.processFileBytes(Main.java:455)
       [dx]     at com.android.dx.command.dexer.Main.access$400(Main.java:67)
       [dx]     at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:394)
       [dx]     at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
       [dx]     at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:131)
       [dx]     at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:109)
       [dx]     at com.android.dx.command.dexer.Main.processOne(Main.java:418)
       [dx]     at com.android.dx.command.dexer.Main.processAllFiles(Main.java:329)
       [dx]     at com.android.dx.command.dexer.Main.run(Main.java:206)
       [dx]     at com.android.dx.command.dexer.Main.main(Main.java:174)
       [dx]     at com.android.dx.command.Main.main(Main.java:91)
       [dx] 1 error; aborting

我删除了我的 libs 文件夹的每个文件“android-supportv4.jar”,并且在 Eclipse 中,我确保在我的库和我的主项目中没有指向该库的链接,但错误仍然存​​在。

我可以通过 Eclipse 构建我的项目,但 Ant 无法构建它(在调试或发布模式下)。

我试过 ant clean 并没有改变任何东西。

如何避免这种令人沮丧的错误?

4

1 回答 1

1

Check your project's libs folder and if there is duplicate jar remove it. I found actionbarsherlock.jar in my project's libs folder and after i'd deleted it, problem solved.

Also check those out; this blog, this question, and this page

于 2013-02-08T00:52:02.450 回答