使用ant或Eclipse编译时出现多个dex文件错误

发布于 2024-12-11 09:25:03 字数 430 浏览 0 评论 0原文

我无法构建我的应用程序 我正在运行今天下载的最新构建工具,这种情况在更新后开始发生。

-dex:
   [dex] Converting compiled files and external libraries into 
         /Users/rob/Repos/my_app/bin/classes.dex...
    [dx] 
    [dx] UNEXPECTED TOP-LEVEL EXCEPTION:
    [dx] com.android.dx.util.DexException: Multiple dex files define 
         Lcom/robaldred/myapp/About$1;

我尝试过清理和重建,我也在 E​​clipse 中尝试过,但它给出了相同的错误。 有人有什么想法吗?我现在就在这里的一堵砖墙上。

I am unable to build my application
I am running the latest build tools downloaded today, this started happening after the update.

-dex:
   [dex] Converting compiled files and external libraries into 
         /Users/rob/Repos/my_app/bin/classes.dex...
    [dx] 
    [dx] UNEXPECTED TOP-LEVEL EXCEPTION:
    [dx] com.android.dx.util.DexException: Multiple dex files define 
         Lcom/robaldred/myapp/About$1;

I have tried cleaning and rebuilding, I've also tried in Eclipse but it gives the same error.
Anyone got any ideas? I'm at a brick wall here now.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

苯莒 2024-12-18 09:25:03

我花了几个小时清理、创建新项目、卸载重新安装 sdk...没有任何效果。我也没有任何库项目(我只是在 lib 下有一些 jar 文件)。然而,最后我修复了它,我的步骤是:

  • 搜索并清理所有 .apk 文件(我在 .svn 文件夹中有一些文件...grr..一些开发人员在 svn 下添加了一些与构建相关的文件夹)
  • 删除 bin 和 gen。
  • 从 Eclipse 项目属性中删除对库 jar 的引用,然后按确定。然后再次将它们添加回来。我有一些java编译的jar库。我不知道为什么我必须将其删除并重新添加回来,但这确实是必要的。

I spent hours cleaning, creating new projects, uninstalling-reinstalling sdk... nothing worked. I didnt have any library project either ( i just had some jar files under lib). Howerver, In the end I fixed it and my steps were:

  • Search and clean all .apk files ( I had some in .svn folder...grr.. some developer had added some build related folders under svn)
  • delete bin and gen.
  • From eclipse project properties remove reference to library jars, press ok. Then again add them back. I had some java compiled jar library. I don't know why I had to remove and add it back, but that surely was needed.
怪我闹别瞎闹 2024-12-18 09:25:03

昨天我的系统(以及工作中的另一个系统)发生了一些事情,其中​​ SDK 想要推送平台工具更新,但后来我根本无法使用它,等等。

我最终将我的 SDK 移开并重新安装它,然后一切都像往常一样进行。我没有遇到你的 dex 特定问题,但我怀疑昨天的更新推送破坏了很多东西。祝你好运。

Something happened yesterday to my system (and another here at work) where the SDK wanted to push the platform tools update but then I was unable to use it at all, etc.

I ended up moving my SDK out of the way and reinstalling it, then everything worked as it always had. I did not have your dex specific issue, but I suspect the update push yesterday broke a good many things. Good luck.

蓝眼睛不忧郁 2024-12-18 09:25:03

您可以:

  • 删除文件夹<.settings>和文件<.classpath><.project>

  • 在 Eclipse 中删除您的项目(右键,),而不删除源文件。

  • 创建一个新的 Android 项目,然后从之前的源中选择

  • 导入外部库(如果构建路径中需要)。

它应该可以解决这个恼人的问题。

You can:

  • Delete folders <.settings>, <bin>, <gen>, and files <.classpath>, <.project> and <project.properties>.

  • Delete your project in Eclipse (right button, <Delete>) without deleting the source files.

  • Create a new Android project and select <Create project from existing sources> from your previous sources.

  • Import external libs, if needed in the build path.

It should solve this annoying problem.

合约呢 2024-12-18 09:25:03

请务必小心项目中附加的/拥有的所有源文件。
我在两种情况下发现了这个问题:

  1. 当我有两个不同的 android 支持库 jar 时
  2. 当我不小心将一些 Facebook src 放入过去时,不是作为库,而是直接放入我的 src 目录

所以所有答案都说您不应该将 bin/ 目录放入类路径中也是正确的,但是在出现以下错误的情况下:

[2013-08-02 20:22:03 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/facebook/android/AsyncFacebookRunner$1;
[2013-08-02 20:22:03 - Activity] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/facebook/android/AsyncFacebookRunner$1;

您应该在项目/库中查找相同的 jar(在大多数情况下,这应该由 Android Eclipse 环境创建)或查看项目附加的所有来源以查找com.facebook.android.AsyncFacebookRunner 类多次出现(如上面的示例代码所示)

Be very careful about all source files you attach to/have in your project.
I found this problem in two situations:

  1. When I have two different android support library jars
  2. When I accidently put in the past some Facebook src not as a library, but directly into my src directory

So all answers which says that you shouldn't put your bin/ directory into class path are also correct, but in situation where you have error like:

[2013-08-02 20:22:03 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/facebook/android/AsyncFacebookRunner$1;
[2013-08-02 20:22:03 - Activity] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/facebook/android/AsyncFacebookRunner$1;

you should look for same jars in project/libraries (this should be founded by Android Eclipse environment in most cases) or look into all sources attached to project to find multiple occurance of (as in example code above) of class com.facebook.android.AsyncFacebookRunner

节枝 2024-12-18 09:25:03

我认为 bin 中的目录从 变为

com/XXX/XXX

classes/com/XXX.

可以清理您的项目并解决它。

I think the directory in bin change from

com/XXX/XXX

to

classes/com/XXX.

You can clean your project and solve it.

怀念你的温柔 2024-12-18 09:25:03

我也看到了同样的问题。如果您使用的是 Android Studio,则需要确保在编译时任何项目中都没有包含“bin”或“gen”文件夹。

删除后我能够成功编译

I was seeing this same problem. If you're using Android Studio, you need to make sure you don't have the 'bin' or 'gen' folders included in any of your projects when you're compiling.

After removing this I was able to compile successfully

笔芯 2024-12-18 09:25:03

如果您因多个 DEX 文件而遇到问题,

请删除整个目标文件夹并再次构建项目。这不会影响您的项目,因为目标文件夹中的所有内容都会重新构建。

If you're having issues because of Multiple DEX files

Remove the entire target folder and build the project again. This won't affect your project cause everything in the target folder is built again.

凉风有信 2024-12-18 09:25:03

将实现 fileTree(include: ['.jar'], dir: 'libs') 更改为
在您的应用程序 gradle.build> 中提供了 fileTree(include: ['
.jar'], dir: 'libs')依赖关系。

确保您的“模块设置”中已更改>依赖项 {include=[*jar] dir=libs} 也是如此。它旁边必须有一个“提供”范围,而不是“实现”。

Change implementation fileTree(include: ['.jar'], dir: 'libs') to
provided fileTree(include: ['
.jar'], dir: 'libs') in your app gradle.build> dependencies.

Make sure it has changed in your Module Settings> Dependencies {include=[*jar] dir=libs} too. It must have a scope of Provided next to it and not Implementation.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文