简体   繁体   中英

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. 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.

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. 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". 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.

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. Eclipse/ADT then created a second copy of these in the gen folder. This question is what tipped me off to look inside the jar.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM