[英]Unable to execute dex: Multiple dex files define… OR NoClassDefFoundError
I've got an Android app which (in theory) can be turned into a library and dropped into an external application. 我有一个Android应用程序(从理论上讲)可以变成一个库,然后放到一个外部应用程序中。 The external app can then create a tab which will contain my app. 然后,外部应用可以创建一个包含我的应用的标签。 The library app is set up in a similar manner to the google-play-services library where the code is stored in a jar file in the libs folder. 该库应用的设置方式类似于google-play-services库,其中代码存储在libs文件夹中的jar文件中。
The first issue I experienced was that I was getting 我遇到的第一个问题是
Unable to execute dex: Multiple dex files define Lcom/MyLibraryApp/R$anim
when I tried to run the external application in the emulator. 当我尝试在模拟器中运行外部应用程序时。 After a lot of googling and dead ends, I was able to get the external app to run by unchecking the "Android Private Libraries" in the "Order and Export" section of the build path menu. 经过大量的搜寻和死胡同之后,我可以通过取消选中构建路径菜单的“订购和导出”部分中的“ Android私有库”来使外部应用程序运行。 But when I go to the tab that calls onto the library app, I get 但是当我转到调用图书馆应用程序的标签时,
java.lang.NoClassDefFoundError: com.MyLibraryApp.SplashScreen
and after checking on here, it seems that the solution to this is to re-check the "Android Private Libraries". 并且在这里检查之后,似乎解决方案是重新检查“ Android Private Libraries”。 So I'm in kind of stuck because either I check the Android Private Libraries and get the Multiple Dex Files issue or un-check it and get a NoClassDefFoundError. 因此,我陷入了困境,因为我要么检查了Android私有库并获得了多个Dex文件问题,要么取消选中了它并获得了NoClassDefFoundError。
Has anyone come across this kind of issue before? 有人遇到过这种问题吗?
Turns out that the issue was that the jar I created for the library app contained the R.class and Manifest.class files from the original application. 事实证明,问题是我为库应用程序创建的jar包含原始应用程序中的R.class和Manifest.class文件。 Eclipse/ADT then created a second copy of these in the gen folder. Eclipse / ADT然后在gen文件夹中创建了它们的第二个副本。 This question is what tipped me off to look inside the jar. 这个问题是什么让我失望的去看罐子里的东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.