简体   繁体   English

无法执行dex:多个dex文件已定义

[英]Unable to execute dex: Multiple dex files define

I know this question has been asked here a few times before. 我知道这个问题已经在这里问过几次了。 But i haven't seen any possible solution yet. 但是我还没有看到任何可能的解决方案。 Before i make the project 'Run as Android Application' , if i do not clean it, i receive the following error and have to restart Eclipse ... and clean again. 在我将项目“以Android应用程序身份运行”之前,如果我不清理它,则会收到以下错误,并且必须重新启动Eclipse ...并再次清理。

Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define
     Lcom/jstun/core/attribute/MessageAttributeInterface;

com.jstun.core... is a part of my src folder, of course i can't remove it. com.jstun.core ...是src文件夹的一部分,我当然不能将其删除。 And even if i remove that package, another package will show up as an error like: 即使我删除该程序包,另一个程序包也会显示为错误,例如:

Unable to execute dex: Multiple dex files define
     Landroid/support/v4/app/ActivityCompatHoneycomb;

I've seen this error since updating to ADT 15, i'm using Eclipse Galileo on Ubuntu Do you have any idea? 自更新为ADT 15以来,我已经看到此错误,我在Ubuntu上使用Eclipse Galileo。 Thanks for any reply! 感谢您的回复!

This is a build path issue. 这是一个构建路径问题。

  • Make sure your bin folder is not included in your build path. 确保您的bin文件夹未包含在您的构建路径中。

  • Right click on your project -> go to properties -> Build Path. 右键单击您的项目->转到属性->构建路径。

  • Make sure that Honeycomb library is in your libs/ folder and not in your source folder. 确保Honeycomb库位于您的libs/文件夹中,而不位于源文件夹中。

  • Include the libraries in libs/ individually in the build path. 在构建路径中分别将库包含在libs/中。

    BTW, you may want to bring in the android-support-v4 library to get Ice Cream Sandwich support instead of the Honeycomb support library. 顺便说一句,您可能想引入android-support-v4库而不是Honeycomb支持库来获得Ice Cream Sandwich支持。

I have encountered a similar error today and the reason was that the support library was referenced by two library projects used by my app project but with different versions. 我今天遇到了类似的错误,原因是我的应用程序项目使用的两个库项目引用了支持库,但版本不同。

In more details: My app depends on 2 library projects 详细信息:我的应用程序取决于2个图书馆项目

  • FaceBookSDK 3.0 -> which is referencing android-support-v4 FaceBookSDK 3.0->引用android-support-v4
  • ActionBarSherlock -> which is referencing android-support-v4 but with a modified version to support maps. ActionBarSherlock->引用android-support-v4,但具有修改后的版本以支持地图。

To solve the problem I had to make FaceBookSDK library depend on ABS library instead of the support library directly. 为了解决该问题,我不得不使FaceBookSDK库依赖于ABS库而不是直接依赖于支持库。

Well for me, I deleted the file in the libs folder called android support v4.jar and it all worked out. 对我来说,我删除了libs文件夹中名为android support v4.jar的文件,并且一切顺利。 Goodluck :) 祝好运 :)

I had the same error happening and every time I fixed it, it would come back after I restarted Eclipse. 我发生了同样的错误,每次修复它时,重新启动Eclipse后都会再次出现。

First of all, as other people said, make sure you do not have multiple copies of the same .jar file around your projects. 首先,正如其他人所说,请确保您的项目中没有同一.jar文件的多个副本。

In my case, I had a main project that used ActionBarSherlock (among other library projects). 就我而言,我有一个使用ActionBarSherlock的主项目(在其他库项目中)。 The trick that worked for me was going into ActionBarSherlock --> Properties --> Java Build path --> Order of Export and unselecting Android Private Libraries . 对我ActionBarSherlock --> Properties --> Java Build path --> Order of Export的技巧是进入ActionBarSherlock --> Properties --> Java Build path --> Order of Export然后取消选择Android Private Libraries Then going into Project -> Clean and now you should be able to build the project correctly. 然后进入Project -> Clean ,现在您应该可以正确构建项目了。

Now, for some reason, every time I restart Eclipse, it automatically enables that checkbox, so I have to repeat this process again. 现在,由于某种原因,每次我重新启动Eclipse时,它都会自动启用该复选框,因此我必须再次重复此过程。

Hope this helps some lost soul out there :) 希望这可以帮助一些迷失的灵魂:)

转到项目/属性和Java构建路径,然后取消选中Android私有库

To me, just go to Project Properties >> Java Build Path >> Order and Export. 对我来说,只需转到项目属性>> Java构建路径>>订单和导出。 Uncheck all external library, as the image bellow. 取消选中所有外部库,如下图所示。 It work for me. 它对我有用。 Hope this help. 希望能有所帮助。

项目属性

I have also faced this problem in my project. 我在项目中也遇到了这个问题。 AVD is not able to reload assets,lib,res and etc folder contexts. AVD无法重新加载资产,lib,res等文件夹上下文。 problem : Dex Loader] Unable to execute dex: Multiple dex files define Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl . 问题:Dex加载程序]无法执行dex:多个dex文件定义了Landroid/support/v4/accessibilityservice/AccessibilityServiceInfoCompat$AccessibilityServiceInfoVersionImpl

Then,I created new projects and copied MainActivity.java , activity_main.xml , drawable context. 然后,我创建了新项目,并复制了MainActivity.javaactivity_main.xml ,可绘制上下文。 Then delete old project from package explore,restart your Eclipse and AVD. 然后从程序包探索中删除旧项目,重新启动Eclipse和AVD。 My project is now working properly.... :) I hope this steps will help u little bit folks..!! 我的项目现在可以正常工作.... :)我希望此步骤对您有所帮助。

I have same issue, what i tried is: 我有同样的问题,我尝试过的是:

  1. List item 项目清单
  2. Open Project Build Path, 打开项目构建路径,
  3. Select "Libraries" tab, 选择“库”标签,
  4. Remove all library except the Android Library 删除除Android库以外的所有库
  5. Adding all required JARs Files, 添加所有必需的JAR文件,
  6. And Done! 并做了!

It works for me, thanks. 对我有用,谢谢。

If some of you facing this problem with facebook-connent-plugin for phonegap 如果您中的某些人遇到了Facebook-connent-plugin for phonegap的问题

try to remove files in bin/class/com/facebook/android directory ! 尝试删除bin / class / com / facebook / android目录中的文件! -> and rebuild ->并重建

As others mentioned, this occurs when you have multiple copies of the same class in your build path, or elsewhere in your setup. 正如其他人提到的那样,当您在构建路径中或安装程序中的其他位置具有相同类的多个副本时,会发生这种情况。

I had added android-support-v4.jar to my libs/ folder, and somehow eclipse added a second copy to bin/classes/android-support-v4.jar. 我已经将android-support-v4.jar添加到我的libs /文件夹中,并且eclipse以某种方式向bin / classes / android-support-v4.jar添加了第二个副本。

You can test for this with 您可以使用

grep -r YourOffendingClassName YourApp | grep -r YourOffendingClassName YourApp | grep jar grep jar

Deleting the extra copy in bin/classes solved the problem - unsure why Eclipse made a copy there. 在bin / classs中删除多余的副本可以解决问题-不确定Eclipse为什么在此处制作副本。

I got this error for another reason. 我收到此错误的另一个原因。 I was mistaking adding both the v4 AND the v13 support library. 我错误地添加了v4和v13支持库。 This was not necessary for me since my minSdkVersion is 15. 因为我的minSdkVersion是15,所以这对我来说不是必需的。

I fixed it by only including the v13 support library. 通过包括v13支持库来解决此问题。 Also, make sure to check mark the library in your exported library build path in eclipse. 另外,请确保在eclipse中选中导出的库构建路径中的库。 I also moved it to the top. 我也将其移至顶部。

Even after going through multiple answers, no solution worked for me. 即使经过多个答案,也没有解决方案对我有用。

I deleted "Android Dependencies" from the build path. 我从构建路径中删除了“ Android Dependencies”。 Added all the jar files again to the build path and the error was gone. 再次将所有jar文件添加到构建路径,错误消失了。 Somehow eclipse seemed to cache the things. 某种程度上,月食似乎可以把事情缓存起来。

I'm leaving this answer for someone who gets in this scenario as I did. 我把答案留给像我一样遇到这种情况的人。

I stumbled here and there before noticing that I mistakenly dragged and dropped the Support Library JAR file into my src folder and it was lying there. 我偶然在这里和那里偶然发现,然后错误地将Support Library JAR文件拖放到了src文件夹中,并且该文件位于该文件夹中。 Since I had no idea how it happened or when I dropped it there, I could never imagine something was wrong there. 由于我不知道它是如何发生的或何时放到那里的,所以我无法想象那里有什么问题。

I was getting the same error, I found the problem after sometime and removed it. 我遇到了同样的错误,一段时间后我发现了问题并将其删除。 Project is now working fine. 项目现在运行正常。

The Solution for me was just to do following things: 对我来说,解决方案是执行以下操作:

  1. ->lib directory in your project and delete any multiple elements. ->项目中的lib目录,并删除任何多个元素。
  2. Project->Properties->Java build Path and delete any Dependency Library was added automatically and not by you! 项目->属性-> Java构建路径并删除任何依赖库是自动添加的,而不是您自己添加的! ->Apply ->申请
  3. Restart Eclipse IDE 重新启动Eclipse IDE
  4. Now Clean the project. 现在清理项目。
  5. Run/Debug on Device/Emulator the project ... Good Luck 在设备/仿真器上运行/调试项目...祝您好运

I have had this issue and that doesn't mean, that the same library is loaded many times but System is trying to load a class with the same name and possibly same package name simultaneously, ie 我遇到过这个问题,但这并不意味着相同的库已多次加载,但是System试图同时加载具有相同名称和可能相同包名称的类,即

  • com.pack1.de and Class Geometry of library1.jar com.pack1.deClass Geometrylibrary1.jar

and another 还有另一个

  • com.pack1.de and Class Geometry of library2.jar. com.pack1.decom.pack1.de Class Geometry library2.jar.

How should you approach? 您应该如何处理? You should analyze which methods are being used, a method of library1.jar or library2. 您应该分析使用了哪些方法,即library1.jar或library2的方法。

There are 2 Solutions, 有2个解决方案,

  1. Rename a packagename and then dalvik interprets, that they are distinct classes 重命名程序包名称,然后dalvik解释为它们是不同的类
  2. Or if you want to risk, purge the class, which doesn't contain the methode, which we really use. 或者,如果您想冒险,请清除不包含我们真正使用的方法的类。

I hope that has clarified this often asked question. 我希望这可以澄清这个常见问题。

My problem at first was: 我最初的问题是:

Unable to execute dex: java.nio.BufferOverflowException. 无法执行dex:java.nio.BufferOverflowException。 Check the Eclipse log for stack trace. 检查Eclipse日志中的堆栈跟踪。

1) I Right click on my project -> Android Tools -> Add Support Library (Run my app...Didn't work so I keep it going...) 2) Right click on my project again -> Properties -> Android -> Check Android 4.1.2 (16) on Project Build Target (Run the app again...and get this: 1)我右键单击我的项目-> Android工具->添加支持库 (运行我的应用程序...没有用,所以我继续使用它...)2)再次右键单击我的项目-> 属性-> Android->在Project Build Target上检查Android 4.1.2(16) (再次运行该应用...并获得以下信息:

Unable to execute dex: Multiple dex files define Landroid/support/v4/app/BackStackState; 无法执行dex:多个dex文件定义了Landroid / support / v4 / app / BackStackState;

3) So I went to the "lib" folder on my project and delete the "old" Android.support.library.jar (Run the app and cross fingers and...) 3)因此,我转到了项目上的“ lib”文件夹 ,并删除“旧的” Android.support.library.jar (运行应用程序,用手指交叉……)

¡IT WORKS! 有用!

Hope it helps someone...Thanks people! 希望它能帮助某人...谢谢人们!

我从构建路径中删除了Android依赖项,并且它起作用了。

This error happened to me when in my app's project I referenced a Library project in my Eclipse workspace (in my case the Facebook SDK) and at the same time included the Facebook SDK as a jar in the libs folder. 在我的应用程序项目中,当我在Eclipse工作区中引用一个Library项目时(在我的情况下为Facebook SDK), 并且同时将Facebook SDK作为jar包含在libs文件夹中时,发生了此错误。 Removing the library reference but keeping the jar in the libs folder removed the error. 删除库引用,但将jar保留在libs文件夹中,可以消除该错误。

I had same problem. 我有同样的问题。 I had to delete the .apk file and then it worked. 我必须删除.apk文件,然后它才能工作。

对我来说,我从lib文件夹中删除了android-support-v4.jar,也从构建路径中删除了它。

  • Right click on project and go to build Path>configuration build path 右键单击项目,然后转到build Path>configuration build path
  • Select library tab and click on support-v4 library and click on remove 选择库选项卡,然后单击support-v4 library ,然后单击删除
  • Click on OK 点击确定

and then clean your project and run it will work :-) 然后清理您的项目并运行它就可以了:-)

In case anyone else bangs their head on this issue like I just did: 如果有人像我刚才那样在这个问题上大打出手:

My case involved a chain of library projects. 我的案件涉及一系列图书馆项目。 Simply doing a project clean on all of the libraries fixed everything 只需对所有库执行干净的项目即可修复所有问题

I found below solution in eclipse...hope it works for you :) 我在日食中找到以下解决方案...希望它对您有用:)

Right click on the Project Name

Select Java Build Path, go to the tab Order and Export

Unchecked your .jar library's

This problem occurs when a same library is added into your project multiple times. 当同一库多次添加到您的项目时,会发生此问题。 If you haven't added the library multiple times intentionaly, check out the dependency/private libraries of the libraries you have added in your project, most probably they have already included a library which is causing this conflict. 如果您没有故意多次添加该库,请检查您在项目中添加的库的依赖项/私有库,很可能它们已经包含了引起此冲突的库。

I was also struggling to find this is issue. 我也很努力地发现这是问题。 In my case what happened is while copying the apk to email (drag drop) - by mistake the apk was pasted in src folder in one of the packages. 在我的情况下,发生的是将apk复制到电子邮件(拖放)时-错误地将apk粘贴到了其中一个软件包的src文件夹中。 After removing the apk from source folder it worked fine. 从源文件夹中删除APK后,它工作正常。

I had this problem in Intellij and it was because the ActionBarSherlock library I added to my project defined the android-support-v4.jar as a compile dependency and this jar was already included in my project so there were multiple copies/version of DEX at compile time. 我在Intellij中遇到了这个问题,这是因为我添加到项目中的ActionBarSherlock库将android-support-v4.jar定义为编译依赖项,并且此jar已包含在我的项目中,因此在编译时间。

The solution was to change the ActionBarSherlock module dependency for this jar to be Runtime instead of compile, as my project was already providing it. 解决方案是将此jar的ActionBarSherlock模块依赖性更改为Runtime而不是编译,因为我的项目已经提供了它。

For me the issue was that, i had added a lib project(autobahn lib) earlier and later switched the to Jar file of the same library.Though i had removed references to the older library project, i was getting this error. 对我来说,问题在于,我早些时候添加了一个lib项目(autobahn lib),后来又切换到了同一库的Jar文件中。尽管我删除了对旧库项目的引用,但是却遇到了这个错误。 Following all the answers here i checked the build path etc. But i haven't added these libs to build path manually. 按照这里所有的答案,我检查了构建路径等。但是我还没有添加这些库来手动构建路径。 So i had nothing to remove. 所以我没有什么要删除的。 Finally came across this folder. 终于遇到了这个文件夹。

bin/dexedLibs bin / dexedLibs

I noticed that there were two jar files with the same name corresponding to autobahn Android which was causing the conflict. 我注意到有两个名称相同的jar文件与导致冲突的Android高速公路相对应。 So i deleted all the jar files in the dexedLibs folder and rebuild the project. 所以我删除了dexedLibs文件夹中的所有jar文件,并重建了项目。 That resolved the issue. 那解决了问题。

To add the myriad of other potential sources... I had updated all the libraries in my project's lib folder but then Eclipse "helpfully" reinstalled all the original libraries. 要添加大量其他潜在资源...我已经更新了项目的lib文件夹中的所有库,但是Eclipse“有帮助地”重新安装了所有原始库。 There was no longer any reference inside Eclipse to these libraries but the external dex-maker program just grabbed all the files in the lib directory and thus got two versions of several library .jar files. Eclipse内不再有对这些库的引用,但是外部dex-maker程序仅获取了lib目录中的所有文件,因此获得了几个库.jar文件的两个版本。

git status identified the new files and git clean -f got rid of them for me (though I sometimes had to wait or restart Eclipse on Windows because it still had the files open from the copy). git status标识了新文件,而git clean -f为我摆脱了它们(尽管我有时不得不等待或重新启动Windows上的Eclipse,因为它仍然可以从副本中打开文件)。

ULTRA simple solution and finest: ULTRA简单的解决方案和最好的解决方案:

Remove everything in Right Click Main Project's Folder -> Properties -> Java Build Path except Android XY (where XY is the version in android). 删除右键单击主项目的文件夹->属性-> Java构建路径中的所有内容,但Android XY(其中XY是android中的版本)除外。 Clean, and Build. 清理并构建。 Done! 做完了!

Make sure before of that to have a single android-support-v4.jar. 在此之前请确保拥有一个android-support-v4.jar。

如果您使用的是cordova,请尝试使用cordova clean命令

暂无
暂无

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

相关问题 无法执行dex:定义了多个dex文件…或NoClassDefFoundError - Unable to execute dex: Multiple dex files define… OR NoClassDefFoundError Eclipse / Java / Android无法执行dex:定义了多个dex文件 - Eclipse/Java/Android Unable to execute dex: Multiple dex files define Android Socialize SDK:无法执行dex:多个dex文件定义 - Android Socialize SDK: Unable to execute dex: Multiple dex files define 无法执行 dex:多个 dex 文件定义了 Lbolts/AggregateException - Unable to execute dex: Multiple dex files define Lbolts/AggregateException 无法执行dex:多个dex文件定义Lcom / facebook / android / AsyncFacebookRunner $ 1; - Unable to execute dex: Multiple dex files define Lcom/facebook/android/AsyncFacebookRunner$1; 无法执行dex:多个dex文件定义了Lcom / google / android / gms / ads / AdActivity; - Unable to execute dex: Multiple dex files define Lcom/google/android/gms/ads/AdActivity; 转换为Dalvik格式失败:无法执行dex:多个dex文件定义Lcom / squareup / okhttp / Address; - Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/squareup/okhttp/Address; 无法执行dex:多个dex文件定义Lcom / google / android / gms / analytics / internal / Command - Unable to execute dex: Multiple dex files define Lcom/google/android/gms/analytics/internal/Command 无法执行dex:多个dex文件定义了&java.lang.NoClassDefFoundError - Unable to execute dex: Multiple dex files define & java.lang.NoClassDefFoundError 无法执行dex:多个dex文件定义Ljavax / ws / rs / core / MultivaluedMap异常 - Unable to execute dex: Multiple dex files define Ljavax/ws/rs/core/MultivaluedMap exception
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM