Android Dex:意外的顶级例外:已添加 [英] Android Dex: UNEXPECTED TOP-LEVEL EXCEPTION: Already added

查看:17
本文介绍了Android Dex:意外的顶级例外:已添加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用依赖于一个库项目.该库项目依赖于 Android Compatibility Package V4.我导出了库项目的依赖项.在我自己的项目中,我已将 ACL V13 添加为依赖项,但是在编译时我收到错误消息,即本质上存在重复依赖项.我以为不导出库项目的依赖可以解决这个问题,但事实并非如此.

My app depends on a library project. This library project depends on the Android Compatibility Package V4. I have NOT exported the library project's dependency. In my own project, I've added ACL V13 as a dependency, but when compiling I get the error that essentially there's a duplicate dependency. I thought not exporting the library project's dependency would resolve this issue, but it's not.

我该如何解决这个问题?

How can I resolve this?

编辑

此外,根据 Android 工具文档:

android-support-v4.jar 和 android-support-v13.jar 的特殊情况.

Special case for android-support-v4.jar and android-support-v13.jar.

我们为这两个库做了一个特例,因为 -v13 包含一个里面有 -v4 的完整版.如果两者都找到,则只有 -v13用过.

We make a special case for these two libraries because -v13 contains a full version of -v4 inside. If both are found, then only -v13 will be used.

所以它应该可以正常工作...

So it should just work...

推荐答案

如果你在不同的项目(libs 项目或标准项目)中使用完全相同的 lib jar,apk 工具会自动删除重复的.

If you use exactly the same lib jar in different projects (libs project or standard projects), the apk tools get rid automatically of the duplicate ones.

当您有两个名称相同但修订版不同的库时,问题就开始了.

The problem starts when you have two libs with the same name but not at the same revision.

android-support-v4.jar 和 android-support-v13.jar 文件可以来自不同的版本,因为在不同的支持包版本中总是有相同的名称(http://developer.android.com/tools/extras/support-library.html#Notes)

The android-support-v4.jar and android-support-v13.jar files can be from different revision since there always have the same name in different support package release (http://developer.android.com/tools/extras/support-library.html#Notes)

我会检查您在主项目和库项目中使用的支持库的版本是否完全相同.

I would check that you use exactly the same revision of the support libs in your main project and in your lib project.

为了确保,将两个支持库 jar(位于 android-sdk 文件夹中)复制到您的项目 libs 文件夹中.

To make sure, copy the two support libraries jars (located in the android-sdk folder) to your projects libs folder.

{android-sdk}/extras/android/support/v4/android-support-v4.jar
AND
{android-sdk}/extras/android/support/v13/android-support-v13.jar

应该可以解决这个问题.

It should get rid of the problem.

这篇关于Android Dex:意外的顶级例外:已添加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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