Andreas H
Andreas H

Reputation: 131

Unable to execute dex: Multiple dex files define Lcom/actionbarsherlock/R$attr

I have created a library project for my app. When I try to add the library to a project, I get the following error when trying to run it:

[2013-02-07 04:51:26 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/actionbarsherlock/R$attr;
[2013-02-07 04:51:26 - testfromlibrary] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/actionbarsherlock/R$attr;

I have added the HoloEverywhere library to my library, whereas I have added the ActionBarSherlock library to HoloEverywhere. I am using Eclipse on Windows 7.

Even though I updated the SDK to the latest version, restarted Eclipse, and cleaned the various projects, the error persists.

Does anyone have any idea on how to solve this error? My bin dir is not included to the build path under properties, and I have tried deleting the bin folder altogether.

Thanks!

Upvotes: 8

Views: 19072

Answers (12)

Taras
Taras

Reputation: 487

If your project is referencing a library project - please check if the library project has the same libs that you are using in your project but different versions. Use same versions everywhere and all should be ok!

Upvotes: 0

Amin SZ
Amin SZ

Reputation: 11

For me, the solution was delete every JAR file in the "bin" folder / directory.

Upvotes: 0

Gene Bo
Gene Bo

Reputation: 12063

For Android Studio - I removed duplicate .jar imports and it was resolved.

Details: I had an app that had a base /common folder and then two folders that inherited from that - a free and paid version of the app. The issue was caused when I had the /common folder and the /free folder both including the same crashlytics jar file in project structure.

Upvotes: 0

Jorge E. Hernández
Jorge E. Hernández

Reputation: 2938

You can use Tattletale

It helps you to identify duplicated classes in your JAR files.

Hope it helps.

Upvotes: 0

user2918326
user2918326

Reputation: 19

Remove all the libraries from Build Path and import the library project that you want to implement.. This works just fine..

Upvotes: 0

methical
methical

Reputation: 131

This happened to me after I changed a regular android project to a library project in order to use it for a Free/Paid project split set up.

Running either of the Free/Paid projects will result in OPs error.

Problem was some left over compilation stuff when the base project was a normal project and not a library project. Just clean the workspace and rebuild all projects. Old compilation junk will be removed and everything will be compiled into correct libraries. Try to rerun project which gave the error and everything should be fine now.

Upvotes: 3

Chriskot
Chriskot

Reputation: 647

I found that if I went into properties -> Java Build Path -> Order and Export and removed the Android Private Libraries then my project built fine. There was another support v4 jar in there which was conflicting with action bar sherlocks support v4 library

Upvotes: 18

Ton Snoei
Ton Snoei

Reputation: 3185

Be sure both projects (the library and the app) don't have the same packagename (within the AndroidManifest)

Upvotes: 2

jony
jony

Reputation: 89

the issue for me was duplicate class files. i had both the package itself and the jar sdk of the package (in libs folder) in the same project.

Upvotes: 3

thalespf
thalespf

Reputation: 388

This issue happens to me when I create a library in conjuction with actionbarsherlock. In this case the eclipse create the R from sherlock in my library and in the project using it.

The solution is delete in your library bin folder only the folder actionbarsherlock that contains the R classes. This inst create anymore, and is present only in your project app.

Upvotes: 8

Matthew Shearer
Matthew Shearer

Reputation: 2795

I had the same issue today. I deleted the .apk file inside /bin, seemed to fix it.

Upvotes: 1

Andreas H
Andreas H

Reputation: 131

I pinpointed the cause of the error to /bin/classes. If I deleted the /classes dir before running the app, the app would compile and run. Of course, when I tried to actually export the app, the /classes dir would come back and along with it the error.

The solution to my problem was to install the latest version of Eclipse. When I export or run the app through the latest installation of Eclipse, the /classes folder does not appear now.

Upvotes: 5

Related Questions