SDK 更新后出现意外的顶级异常 [英] Unexpected Top-Level Exception after SDK Update

查看:21
本文介绍了SDK 更新后出现意外的顶级异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个 Android 项目,该项目的构建路径中有一个 Android 库项目.这两个项目的 libs 文件夹和构建路径中都有 AdWhirl SDK 库.

I'm working on an Android Project which has an Android Library Project in his Build Path. Both projects have the AdWhirl SDK library in their libs folder and Build Path.

现在,由于将 android sdk 工具更新到 r15,主项目的 ant 构建因以下异常而失败:

Now since updating android sdk tools to r15 the ant build of the main project fails on following exception:

[dx] UNEXPECTED TOP-LEVEL EXCEPTION:
       [dx] java.lang.IllegalArgumentException: already added: Lcom/adwhirl/AdWhirlLayout$AdWhirlInterface;
       [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:95)
       [dx] 1 error; aborting

现在我尝试从主项目中删除 AdWhirl SDK 库并将其从库项目中导出.现在 ant 构建工作正常,但是在任何 android 设备上从 eclipse 启动应用程序时,都会抛出一些 ClassNotFoundExceptions.

Now i tried to remove the AdWhirl SDK lib from the main project and export it from the Library project. Now the ant build works, but when starting the application from eclipse on any android device, there will be thrown some ClassNotFoundExceptions.

实际上我可以选择使用 ant 构建或在 eclipse 中调试,但我需要这两种变体.

Actually i have the choice to build with ant or debug in eclipse, but i need both variants.

推荐答案

在我看来,Android 库项目从一开始就没有设计好,但是对于消费者开发者来说,这可能不是一个真正的问题,只要在每次SDK升级过程中保持这样并且行为完全相同.

From my point of view, Android Library Project is not well-designed even from the very beginning, however, this could not be a real problem for consumer developer, as long as it stays like this and behavior exactly the same during each SDK upgrade.

但事实并非如此,Android 开发团队在最近的几个版本中(可能从 r14 开始)开始对整个事情进行改造,并承诺在下一个版本中提供最终解决方案.这使我们的持续开发目前处于极其不稳定的阶段,我没有在我的项目中使用 ant,但是在每次 SDK 升级期间使用 Maven 管理库更改时遇到了类似的问题.看起来 Android 开发团队甚至难以仅通过他们的官方 ADT 插件来管理更改(请查看此 博客),更不用说非官方支持的构建工具,如 Ant 或 Maven.

But it is not, Android dev team started revamp the whole things during several recent release (probably since r14), and promise us a ultimate solution in next coming release. This leaves our continuous development in a extremely unstable stage at the moment, I don't use ant with my projects but had similar sort of problems using Maven manage library change during each SDK upgrade. Looks like Android Dev team even had difficulties manage the changes purely from their official ADT plugin (check out this blog), not to mention the un-official supported build tools like Ant or Maven.

我已经为你做了一些搜索,在 Android JIRA 系统中发布了一个线程,与你的情况非常相似,并提供了一些解决方法(ant 脚本中的脏修复),请查看 克里斯的第 16 条评论,看看是否对您有帮助.

I've done some search for you, there is a thread posted in Android JIRA system which is quite similar to your situation, and come with some workarounds (dirty fix in ant script), check out comments 16 by chris, see if this helps you out.

这篇关于SDK 更新后出现意外的顶级异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆