简体   繁体   English

多个dex文件 - 转换为Dalvik格式失败 - 无法执行dex

[英]Multiple dex files - Conversion to Dalvik format failed - Unable to execute dex

I have 2 app versions - pro and lite. 我有2个应用程序版本 - 专业版和精简版。 They are both already on the market at v1.01. 它们都已在v1.01上市。 I am trying to release v1.1 for both. 我试图为两者发布v1.1。 This update includes SwawrmConnect integration in order to use their global leaderboards. 此更新包括SwawrmConnect集成,以便使用其全局排行榜。

I should start off by saying I know I am not maintaining my code correctly. 我应该首先说我知道我没有正确维护我的代码。 I have 2 completely separate apps and that share probably 90% of their code. 我有2个完全独立的应用程序,可能共享90%的代码。 I maintain them separately because after a week or 2 or 3 of failing to figure out how to do a library and share code, I gave up and just went this way with it. 我单独维护它们是因为经过一周或者2或3次未能弄清楚如何建立一个库并共享代码之后,我放弃了,就这样用它来了。

SwarmConnect is the first jar I have used and had to make a library to two apps (see screenshot of file structure below). SwarmConnect是我使用的第一个jar,必须为两个应用程序创建一个库(请参阅下面的文件结构截图)。

Right now my lite version is working and is ready for release. 现在我的Lite版本正在运行并准备发布。 I am now trying to get my pro version to where it needs to be for release. 我现在正试图将我的专业版本发布到需要发布的位置。 I am fairly certain all java/xml files are up to date and ready. 我相当确定所有java / xml文件都是最新的并准备好了。 When I went to run the pro version in the emulator, I get the below error: 当我在模拟器中运行专业版时,我收到以下错误:

[2013-04-18 11:24:41 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/swarmconnect/loopj/android/http/AsyncHttpResponseHandler;
[2013-04-18 11:24:41 - BibleTriviaPro] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/swarmconnect/loopj/android/http/AsyncHttpResponseHandler;

Things I've tried: 我试过的事情:

  • Clean/rebuild 清洁/重建
  • Update Eclipse 更新Eclipse
  • Delete bin and gen folders 删除bin和gen文件夹
  • Restart Eclipse 重启Eclipse
  • Plus some other stuff 加上其他一些东西

My file structure: 我的文件结构:

在此输入图像描述

Could the problem be is I am trying to use SwarmConnect as a library for 2 projects (lite and pro)? 可能问题是我正在尝试使用SwarmConnect作为2个项目(lite和pro)的库?

EDIT: 编辑:

Below is the file structure for the lite version that is working perfectly. 下面是完美运行的lite版本的文件结构。 Compiles and runs on emulator. 在模拟器上编译并运行。

在此输入图像描述

Coincidentally I ran into the same issue just day before yesterday. 巧合的是,我前天遇到了同样的问题。 Here's what I suggest you to do. 这是我建议你做的。

First and foremost make sure that you have a backup of all the jars presently residing in the 'Android Dependencies'/'libs' folder. 首先要确保您拥有目前驻留在“Android Dependencies”/“libs”文件夹中的所有jar的备份。

Now, lets fix the lite version first by following these steps. 现在,我们首先按照以下步骤修复lite版本。

  1. Remove all jar files except android-support-v4.jar from the 'Android Dependencies' folder under Project Explorer in Eclipse. 从Eclipse中的Project Explorer下的'Android Dependencies'文件夹中删除除android-support-v4.jar之外的所有jar文件。

  2. Similarly remove all Jar files except android-support-v4.jar from the libs folder under Project Explorer in Eclipse. 同样,从Eclipse中的Project Explorer下的libs文件夹中删除除android-support-v4.jar之外的所有Jar文件。

  3. Now Right click on your project-> Select Properties-> Select Java Build Path-> Select Add External JARs. 现在右键单击您的项目 - >选择属性 - >选择Java构建路径 - >选择添加外部JAR。 Add all the necessary jar files (just make sure you add a particular jar file only once). 添加所有必需的jar文件(只需确保只添加一个特定的jar文件)。

Finally clean the project and build it. 最后清理项目并构建它。 Now apply the same sequence of steps to the pro version. 现在将相同的步骤序列应用于专业版。 That should do it. 应该这样做。

UPDATE:- In case you see Eclipse cribbing about some compile time errors after doing all this all you might have to do is to just fix those compile time errors by doing the necessary imports by pressing Ctrl + Shift + O . 更新: - 如果您在完成所有这些操作后看到Eclipse发生了一些编译时错误,那么您可能需要做的就是通过按Ctrl + Shift + O执行必要的导入来修复这些编译时错误。

[I assume that there's no linkage between the pro and lite versions of the project in terms of source dependencies etc.. what I mean to say basically they are totally independent.] [我假设项目的专业版和精简版之间在源依赖等方面没有联系。我的意思是基本上它们是完全独立的。]

Hope this helps. 希望这可以帮助。

I strongly suspect this is your problem 我强烈怀疑这是你的问题

  1. Right click your project 右键单击您的项目
  2. Look under the "Android" option 查看“Android”选项
  3. In the lower pane look if "Swarm Connect" is present 在下部窗格中查看是否存在“Swarm Connect”
  4. If not, add it (though I really suspect it already is there) 如果没有,添加它(虽然我真的怀疑它已经存在)
  5. Remove Swarm.jar from your libs directory 从libs目录中删除Swarm.jar

the reason being: when you add a library project to an Android project in Eclipse, it doesn't show up in your libs directory. 原因是:当您将库项目添加到Eclipse中的Android项目时,它不会显示在您的libs目录中。 I actually tried to add just the .jar file to a project and got told that that was the wrong approach (at least until API 14, I think). 我实际上试图将.jar文件添加到项目中并被告知这是错误的方法(至少在API 14之前,我认为)。

My guess is, in your "non-pro" version you didn't link it in the project options and thus it still compiles correctly. 我的猜测是,在你的“非专业”版本中你没有将它链接到项目选项中,因此它仍然可以正确编译。 Still, you should link it the way I just described to avoid problems when the library tries to access its own resources. 尽管如此,您应该按照我刚才描述的方式链接它,以避免在库试图访问自己的资源时出现问题。

The above solution didnt work for me,All i had to do was add the jars in the libs folder externally and Uncheck Android private libraries under the order and export tab. 上面的解决方案对我来说不起作用,我只需要在外部的libs文件夹中添加jar并在订单和导出选项卡下取消选中Android私有库。

 right click--
             java build path--
                               order and export tab ->Uncheck Android private libraries 
                                   and add jars in the libs folder externally.

do the above steps. 做上述步骤。 Dont know why this is happening. 不知道为什么会这样。

I tried @Sriram's answer above. 我试过@Simram的答案。 It didn't work. 它没用。

Then I had to remove the libraries from the Project->Properties->Java Build Path->Libraries place and add the actual jar's (I needed both android-support-v4.jar and android-support-v13.jar) into libs folder of my project. 然后我不得不从Project-> Properties-> Java Build Path-> Libraries的地方删除库,并将实际的jar(我需要android-support-v4.jar和android-support-v13.jar)添加到libs文件夹中我的项目。 Then it worked: 然后它工作:

最终结构

(note that there is no "Referenced Libraries" folder) (请注意,没有“Referenced Libraries”文件夹)

I got this error because I used the entire Android Development Kit installer (Eclipse plus SDK, dated 2/6/2013). 我收到此错误是因为我使用了整个Android Development Kit安装程序(Eclipse plus SDK,日期为2013年2月6日)。 The only way I was able to get rid of it was to uninstall all of that, and separately install Eclipse For Java Developers from eclipse.org, and the Android SDK only from the Android site. 我能够摆脱它的唯一方法是卸载所有这些,并从eclipse.org单独安装Eclipse For Java Developers,仅从Android站点安装Android SDK。 The Eclipse that comes with the kit has some funny ideas about where to include libraries from, not to mention vestigial pieces of c++ and gdb support. 该工具包附带的Eclipse有一些有趣的想法,关于在哪里包含库,更不用说c ++和gdb支持的残留部分了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 转换为Dalvik格式失败:无法执行dex:多个dex文件定义Lcom / squareup / okhttp / Address; - Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/squareup/okhttp/Address; 转换为Dalvik格式失败:无法执行dex:定义了多个dex文件 - Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files are defined 无法执行dex和转换为Dalvik格式失败 - Unable to execute dex & Conversion to Dalvik format failed java android Eclipse Retrofit 2.0 转换为 Dalvik 格式失败:无法执行 dex:多个 dex 文件定义了 Lretrofit2/Converter - java android Eclipse retrofit 2.0 Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lretrofit2/Converter 转换为Dalvik格式失败:无法执行dex:Java堆空间 - Conversion to Dalvik format failed: Unable to execute dex: Java heap space 获取错误:转换为Dalvik格式失败:无法执行dex: - Getting Error: conversion to Dalvik format failed: Unable to execute dex: Android:转换为Dalvik格式失败:无法执行dex:null - Android: Conversion to Dalvik format failed: Unable to execute dex: null 类型转换为Dalvik格式失败:无法执行dex:java.nio.BufferOverflowException - Type Conversion to Dalvik format failed: Unable to execute dex: java.nio.BufferOverflowException 无法执行dex:多个dex文件已定义 - Unable to execute dex: Multiple dex files define 无法执行dex:定义了多个dex文件…或NoClassDefFoundError - Unable to execute dex: Multiple dex files define… OR NoClassDefFoundError
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM