Unable to execute dex: Multiple dex files define Lcom/myapp/R$array;

AndroidEclipseAdtAndroid Sdk-ToolsDex

Android Problem Overview


Since updating to ADT 14 I can no longer build my project. It was building fine prior to updating.

The error:

[2011-10-23 16:23:29 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/myapp/R$array;
[2011-10-23 16:23:29 - myProj] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/myapp/R$array;

Similar issues have been reported and I have tried the suggestions there including

  • Restarting Eclipse.
  • Cleaning the project and rebuild - Disable "Project->Build Automatically" option, then "Clean" and "Build" project, then try to run. reset "Build Automatically" option to On
  • Re-installing the Android Developer Tools
  • Re-installing Eclipse (updated to the latest version 3.7.1)
  • Created a new project importing from the file system
  • Created a new project from subversion.

Android Solutions


Solution 1 - Android

I had the same problem, quite weird because it was happening only when using Eclipse (but it was OK with Ant). This is how I fixed it:

  • Right click on the Project Name

  • Select Build Path -> Configure Build Path

  • In Java Build Path, go to the tab Order and Export

  • Uncheck your .jar library

Only sometimes: In Order and Export tab I did not have any jar library there, so I have unchecked Android Private Libraries item. Now my project is running.

Solution 2 - Android

My problem was resolved after cleaning up some directories and files left over from the previous versions of the tools. ADT Rev 14 changes where binaries are stored. I deleted the entire bin directory, restarted Eclipse and cleaned the build and forced a rebuild. That seemed to do the trick initially but the problem came back after the next run.

I finally discovered that my bin directory was included in the project build path. I excluded bin from the build path and repeated the steps above. This resolved my problem.

Solution 3 - Android

[Solved for me]

Eclipse project properties->Java build path->Order and export

Uncheck Android private libraries.

Solution 4 - Android

None of the above helped. It was a simple problem in the end.

I had a project which uses the FacebookSDK and ViewPagerIndicator as library projects. All were built on Android API 16 and those two projects used the android support library vX (X not being 16!)

I added an external JAR to both those projects and pointed it to \extras\android\v4... And also removed the v4 jar I had in their libs folders.

Clean all projects and re-build.

Voilla!

The exact error I was receiving: Unable to execute dex: Multiple dex files define Landroid/support/v4/view/PagerAdapter; Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Landroid/support/v4/view/PagerAdapter;

Solution 5 - Android

This problem was happening me, I had an external .jar in my libs folder called gson-2.2.2.jar but for some reason there were two of them, gson-2.2.2.jar and gson-2.2.2.jar(1), I simply deleted the latter and my project built fine again.

Solution 6 - Android

  1. Close eclipse.
  2. Delete bin folder inside your project folder.
  3. Start eclipse and clean your project.
  4. Now run and the problem should be gone

Solution 7 - Android

As others have mentioned, this occurs when you have multiple copies of the same class in your build path - including bin/ in your classpath is one way to guarantee this problem.

For me, this occurred when 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.

Deleting the extra copy in bin/classes solved the problem - unsure why Eclipse made a copy there.

You can test for this with > grep -r YourOffendingClassName YourApp | grep jar

Solution 8 - Android

For me, I just right click on project -> Build path -> configure build path -> Libraries -> remove dependency

after it works.

Solution 9 - Android

This error can happen if you have two jars that contains the same class names, e.g. I had two library: jsr311-api-1.1.1.jar, and jersey-core-1.17.1.jar, both containing the class javax.ws.rs.ApplicationPath. I removed jsr311-api-1.1.1.jar and it worked fine.

Solution 10 - Android

I was getting this error after adding the facebooksdk.jar to a project that already had dependencies on the android-support-v4.jar. Since the facebooksdk.jar already includes its own android-support-v4.jar there were conflicts. Removing the earlier android-support-v4.jar from the projects Properties / Java Build Path / Libraries resolved the issue for me.

Solution 11 - Android

Go to Project/properties and Java Build Path and unchecked the Android Private Libraries.

This is also another case for this kind of error

Done

Solution 12 - Android

I removed Android dependencies from build path and it worked.

Edit: ignore that. I had same jar in my maven dependencies and libs folder. I removed the one at the lib folder.

Solution 13 - Android

You have probably installed r14, this error may have been caused due to the platform tools update, you have to re-install your sdk

Solution 14 - Android

For me this problem only exists as long as there are Android library projects involved in my project. So when I remove all the libraries and do as you said I can run my app again. If there are libraries involved even the bin-removal-trick trick won' work.

I don't get why this bug first appeared today since I'm using ADT 14 for several days now. Well there were other bugs that kept me happy though.

Solution 15 - Android

Deleting the bin folder was not enough, I also deleted the gen folder. Then after two rebuilds the dex error message was gone.

Solution 16 - Android

Select the project in Project Explorer, right-click and select Properties -> Java Build Path -> Source -> Check the box for Allow output folders for source folders

Solution 17 - Android

I was basically facing the same issue. I deleted the BIN folder, then removed unused jar files for Order and Import from eclipse. IT WORKED after that

Solution 18 - Android

I'm late to this party, but adding my own experience so I can find it again later :)

I ran into this problem after upgrading the android sdk and eclipse ad-ins. No upgrade goes unpunished!

The problem for me was related to library projects, my app references both standard java projects and android library projects. I noticed the Java Build Path settings were including the android library projects src and res folders in the Source list (upvotes to everyone that mention bin in source being issue, src and res was also an issue.)

So the solution was:

  1. Remove all referenced Android libraries source and project references from the Java Build Path section of the settings in both Source list and Project list
  2. Make sure pure java dependencies are listed in Project list, and Checked in the Order and Export tab so the classes are included in the apk
  3. Make sure all Android library dependencies are listed on the Android section of project properties, in the library section below the checked SDK versions.

It was along way to piece all that together from the other solutions! Phew!

Solution 19 - Android

I ran into this when I upgraded from adt 14 to 15 and to get it to work I ended up just deleting the .eclipse folder (along with my settings) and re-installing the adt 15.

Solution 20 - Android

After reading Terrys response about deleting the bin directory and Larrys about the the location of the ANT directory:

I moved the files located in my projects BIN directory to the BIN/CLASSES and im up and running.

Edit 1 Then failed on second run...doh

Edit 2 So closed Eclipse moved files back to original location and its all working... um what? I don't pretend to know why this worked. Will update if any changes.

Edit 3 I have noted from my backups that there were indeed duplicate files in the BIN directory and BIN/CLASSES.

So the answer is: don't have files in both locations. At least for me that's what worked.

Solution 21 - Android

Modify your eclipse.ini file and set the maximum memory parameter to

-Xmx1024m

Then restart your computer.

It worked for me.

Solution 22 - Android

found a solution i believe??

    [2013-04-28 23:56:09 - Dex Loader] Unable to execute dex: Multiple dex files define Lcom/coremedia/iso/AbstractBoxParser$1;

Where it says : "Lcom/coremedia/iso/AbstractBoxParser$1" that just happen to be the location of the library I imported that was causing the issue. Looked for com.codemedia.iso.AbstractBoxParser$1.class and .AbstractBoxParser.class.... took that jar, unpackaged it, removed both of those files, then repackaged as a .zip, added to library, cleaned and worked! no more conflict for me! (also no updates or additional downloads)

Solution 23 - Android

I had two different versions of Cordova .jar-files in my libs folder, I deleted the one I wasn't even using and it worked right away. Weird because I didn't notice that before and it worked before and then suddenly stopped working...

Solution 24 - Android

The ADT R14 update changes where the classes go to the bin/classes directory (see http://tools.android.com/recent/buildchangesinrevision14). If you are using ANT, you should change the path for your classes from bin to bin/classes. This worked for me.

Solution 25 - Android

Solution for me:

  1. BACK UP YOUR CODE!

  2. Navigate to your project workspace (not your project) and run the following commands:

    dev1:workspace$ cd ~/Documents/workspace/.metadata/.plugins/ dev1:workspace$ rm -rf org.eclipse.core.resources

  3. Navigate to your Eclipse directory and type this command:

    dev1:eclipse$ ./eclipse clear

  4. Eclipse will start with an empty workspace - don't worry your projects are still there. Simple create new project from existing resource and things should be gravy.

The exact error I was receiving: [2012-02-07 14:15:53 - Dex Loader] Unable to execute dex: Multiple dex files define Landroid/support/v4/view/PagerAdapter; [2012-02-07 14:15:53 - ProjectCloud] Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Landroid/support/v4/view/PagerAdapter;

Solution 26 - Android

I have several library projects with the same package name specified in the AndroidManifest (so no duplicate field names are generated by R.java). I had to remove any permissions and activities from the AndroidManifest.xml for all library projects to remove the error so Manifest.java wasn't created multiple times. Hopefully this can help someone.

Solution 27 - Android

After trying all the other suggestions with no luck, I deleted all the contents of my projects 'bin' directory, then ran eclipse again and it worked.

Solution 28 - Android

I converted a non-library project to a library project, but it had a previously built jar file in the libs folder. Removing this jar file caused this error to go away.

Solution 29 - Android

I was facing the same issue then i saw while pushing my app some jar files which were loaded twice hence multiple dex error .Just go to your project properties -> Java Build Path and try unchecking jar which is being loaded twice.

Solution 30 - Android

[Solved for me]

by removing the duplicate library "JAR file" then remove BuildConfig.java file, Clean project and its work.

Solution 31 - Android

Try deleting R.java and letting eclipse re-generate it.

Solution 32 - Android

I had a similar problem when I added ActionBarSherlock as a library in my project. Eclipse ADT v21.0 pre-created dex files supposedly for faster building of the project. These dex files were the same as some of the jar files in my lib folder. So just keep one and delete the other. I deleted the ones in the lib folder as the dexed files were generating automatically.

Solution 33 - Android

I am facing the same problem. The problem I found that I have a library project, in that project's manifest file, there is no targetSdkVersion property. I have added that property under (uses-sdk) tag. Then clean my project. Now my app runs normally.

Solution 34 - Android

Make sure that "android-support-v4.jar" is unchecked in Order and Export tab under Java Build Path

Follow the steps:

  1. Project Properties
  2. Java Build path
  3. Order and Export
  4. Uncheck "android-support-v4.jar"

Solution 35 - Android

I had tried most of the above solution and in past some of them had worked.

But this time none of them worked, so i had deleted my library project's .jar file. and rebuild both library and application project.

And this time it's worked!

Solution 36 - Android

NON OF THE ABOVE METHODE WORKED FOR ME BUT MINE IS WORKED LIKE A CHARM!

The problem happens when user builds the dependent library with eclipse. So to get the solution

Step 1: Delete the library (like support library project v4 or v13) from Eclipse with delete workspace source permanantly

Step 2: Re import the library and include it to your project

Step 3: Clean and Rebuild

DONE!

Solution 37 - Android

Found another scenario where this issue happens: The problem was that the libs folder was used as a Source in the project preferences, so it was exported twice. Resolved by right clicking on the libs folder -> Build Path -> Remove from Build Path

Solution 38 - Android

This happen when in our app, we have libs folder with gson jar (eg: gson-2.2.4.jar). In sametime, our Google Play Service library already have Gson as well.

i have remove it from my app and its work fine now.

Solution 39 - Android

This was the top result when I searched for this error in Google.

Though the question doesn't ask how to solve this issue in regards to React Native, I thought I would share anyway for anyone who ends up here and is using React Native.

From the project root run:

  • cd android && ./gradlew clean [Mac - Bash Terminal]
  • cd android & gradlew clean [Windows - Command Prompt]

Then react-native run-android to build and run again.

Solution 40 - Android

I resolved this issue in my project by deleting a library:

Reason: I included a library-project in my project, and mistakenly did not removed the previous lib from my project, so when I was running the project then same library dex files were generating twice, when I removed the same-library from lib folder of my project, the error gone away and build was created successfully, I hope others may face the same issue.

Solution 41 - Android

I had two related but not identical guava libraries in the /libs directory, after I removed one, the problem went away.

Solution 42 - Android

For me I had pointed to a jar file in my builtPath which wasn't actually in that path anymore!

Solution 43 - Android

I got the same error message with the GooglePlayService library project google-play-services.jar .

We use maven, for this reason I have to add the Library in my local maven repository.(mvn install:install-file -Dfile=xxx)

Now the library is twice in the "Java Build Path" -> Libraries.

  • once in Android Dependencies
  • and once in the Maven Dependencies.

To fix the problem I need to remove the library from the google-play-services_lib/libs directory (the jar it is used automatically)

Solution 44 - Android

I had this problem and solved it by changing the path of the. jar for change directory, but the. jar pulled the other side, change the path and I entered without problem

Solution 45 - Android

i had the same problem unable to execute multipledex files in android --lorg\xhtml\CSS

i deleted 2external jars files in lib folder--core-renderer-3043e0f89ffb2.jar

core-renderer-minimal-e70d6a.jar and my project built fine again...

Solution 46 - Android

In my case, I delete the ".apk" file in the "src/com/..." directory, clean the project and run.

I had tried all the previous suggestions and did not work for me!

Solution 47 - Android

Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/google/zxing/BarcodeFormat;

Posting this answer for those receiving this error with regards to the barcode scanner plugin from zxing.

Just delete the jar file in the libs folder. Should be project/libs/com.google.zxing.client.android.captureactivity.jar

Solution 48 - Android

This error occurred to me when I imported a .jar file (as a matter of fact it was httpmime-4.3.jar) and tried to use it. For me the solution was easy: I removed the .jar file from the libs folder and deleted it from Order and Export. Ran the project again, it worked, so I added the .jar file again and it was finally okay.

Solution 49 - Android

The issue is that "Android Dependencies" keep the reference to the old AdMob SDK even after:

  • remove the old admob sdk from build path
  • ant clean
  • eclipse clean
  • delete the bin and gen folders manually
  • close / open eclipse
  • update sdk tools
  • update adt

The solution is to actually delete the AdMob SDK JAR from your computer, not just from the project.

Solution 50 - Android

Check that your bin folder is not in the build path.

Solution 51 - Android

go to \bin\dexedLibs and remove all the jars of the already removed libraries, then clean

Solution 52 - Android

Spliting Google Play Service could help you : https://developers.google.com/android/guides/setup#split

so instead of adding just play-services :

compile 'com.google.android.gms:play-services:7.5.0'

you add only what you need :

// Google Maps only
compile 'com.google.android.gms:play-services-maps:7.5.0'

Solution 53 - Android

If you use 'com.google.android.gms:play-services' You can add what you really need to look at the following list:

Google+ com.google.android.gms:play-services-plus:10.0.1
Google Account Login com.google.android.gms:play-services-auth:10.0.1
Google Actions, Base Client Library com.google.android.gms:play-services-base:10.0.1
Google Address API com.google.android.gms:play-services-identity:10.0.1
Firebase App Indexing com.google.firebase:firebase-appindexing:10.0.1
Google Analytics com.google.android.gms:play-services-analytics:10.0.1
Google Awareness com.google.android.gms:play-services-awareness:10.0.1
Google Cast com.google.android.gms:play-services-cast:10.0.1
Google Cloud Messaging com.google.android.gms:play-services-gcm:10.0.1
Google Drive com.google.android.gms:play-services-drive:10.0.1
Google Fit com.google.android.gms:play-services-fitness:10.0.1
Google Location and Activity Recognition com.google.android.gms:play-services-location:10.0.1
Google Maps com.google.android.gms:play-services-maps:10.0.1
Google Mobile Ads com.google.android.gms:play-services-ads:10.0.1
Google Places com.google.android.gms:play-services-places:10.0.1
Mobile Vision com.google.android.gms:play-services-vision:10.0.1
Google Nearby com.google.android.gms:play-services-nearby:10.0.1
Google Panorama Viewer com.google.android.gms:play-services-panorama:10.0.1
Google Play Game services com.google.android.gms:play-services-games:10.0.1
SafetyNet com.google.android.gms:play-services-safetynet:10.0.1
Android Pay com.google.android.gms:play-services-wallet:10.0.1
Android Wear com.google.android.gms:play-services-wearable:10.0.1

Solution 54 - Android

Delete generated R package from your referenced library. Sometimes Clean and Rebuild doesn't remove old R generated files.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionterryView Question on Stackoverflow
Solution 1 - AndroidMarco BonifaziView Answer on Stackoverflow
Solution 2 - AndroidterryView Answer on Stackoverflow
Solution 3 - Androiduser802467View Answer on Stackoverflow
Solution 4 - AndroidRoy WeinbergView Answer on Stackoverflow
Solution 5 - AndroidTomSelleckView Answer on Stackoverflow
Solution 6 - AndroidMohit marwalView Answer on Stackoverflow
Solution 7 - AndroidchaqkeView Answer on Stackoverflow
Solution 8 - AndroidsonidaView Answer on Stackoverflow
Solution 9 - AndroidMateus ViccariView Answer on Stackoverflow
Solution 10 - Androidpontiac_venturaView Answer on Stackoverflow
Solution 11 - AndroidHiren PatelView Answer on Stackoverflow
Solution 12 - AndroidHadi TokView Answer on Stackoverflow
Solution 13 - AndroidRenoView Answer on Stackoverflow
Solution 14 - AndroidmephjuView Answer on Stackoverflow
Solution 15 - AndroidRudolf PolzerView Answer on Stackoverflow
Solution 16 - AndroidprasantasingView Answer on Stackoverflow
Solution 17 - AndroidAhsan ZaheerView Answer on Stackoverflow
Solution 18 - AndroidJayView Answer on Stackoverflow
Solution 19 - AndroidJake1164View Answer on Stackoverflow
Solution 20 - AndroidHostMyBusView Answer on Stackoverflow
Solution 21 - AndroidTruncarlosView Answer on Stackoverflow
Solution 22 - Androidjp093121View Answer on Stackoverflow
Solution 23 - AndroidDediqatedView Answer on Stackoverflow
Solution 24 - AndroidLarry BorsatoView Answer on Stackoverflow
Solution 25 - AndroidCooksterView Answer on Stackoverflow
Solution 26 - AndroidJared RummlerView Answer on Stackoverflow
Solution 27 - AndroidJPBView Answer on Stackoverflow
Solution 28 - AndroidPacificSkyView Answer on Stackoverflow
Solution 29 - AndroidNaviView Answer on Stackoverflow
Solution 30 - AndroidAbuQauodView Answer on Stackoverflow
Solution 31 - AndroidBlaskoviczView Answer on Stackoverflow
Solution 32 - AndroidRaWaView Answer on Stackoverflow
Solution 33 - AndroidDineshView Answer on Stackoverflow
Solution 34 - AndroidMuhamed Riyas MView Answer on Stackoverflow
Solution 35 - Androidhi0001234dView Answer on Stackoverflow
Solution 36 - AndroidSazzad Hissain KhanView Answer on Stackoverflow
Solution 37 - AndroidDoron ZehaviView Answer on Stackoverflow
Solution 38 - AndroidAbuQauodView Answer on Stackoverflow
Solution 39 - AndroidRobView Answer on Stackoverflow
Solution 40 - AndroidNaveed AhmadView Answer on Stackoverflow
Solution 41 - AndroidaezView Answer on Stackoverflow
Solution 42 - AndroidSaraView Answer on Stackoverflow
Solution 43 - AndroidGugelhupfView Answer on Stackoverflow
Solution 44 - AndroidFernandoView Answer on Stackoverflow
Solution 45 - Androiduser1859771View Answer on Stackoverflow
Solution 46 - AndroidItsMeMarioView Answer on Stackoverflow
Solution 47 - AndroidpdxwebdevView Answer on Stackoverflow
Solution 48 - AndroiderdomesterView Answer on Stackoverflow
Solution 49 - AndroidthiagolrView Answer on Stackoverflow
Solution 50 - AndroidSterling DiazView Answer on Stackoverflow
Solution 51 - AndroidMuhammed RefaatView Answer on Stackoverflow
Solution 52 - AndroidsoniqueView Answer on Stackoverflow
Solution 53 - AndroidAhmad AghazadehView Answer on Stackoverflow
Solution 54 - AndroidalexView Answer on Stackoverflow