34

I have implemented the new Facebook SDK 3.0 beta. The library project contains the Android support library v4. I also have the support library on my own proyect (a different version though). When I add the Facebook SDK as a library I get the next error on the console:

Jar mismatch! Fix your dependencies
Found 2 versions of android-support-v4.jar in the dependency list,
but not all the versions are identical (check is based on SHA-1 only at this time).
All versions of the libraries must be the same at this time.

I've tried to exclude the libs folder on the buildpath, but the error remains.

I have to put the same .jar in both places. Am I missing something here? The idea is to use the support library of my own project (to keep it updated).

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
nsemeniuk
  • 1,171
  • 1
  • 13
  • 24

3 Answers3

122

It seems like the different projects are using two separate support libraries and therefore the checksum is different.

You must repeat this for both the Facebook SDK project and the app you are building.

What I do when I get this error is:

  1. Right click the project.

  2. Hover over Android Tools.

  3. Click on "Add support library..."

  4. Accept the downloading of the library.

This insures two things: a. you get the newest version of the support library from the Google sources, and b. you have the EXACT same library in all your projects.

Happy coding!

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
thepoosh
  • 12,497
  • 15
  • 73
  • 132
  • 1
    Ok, so i have to update both (my proyect and FB's library proyect) every time there is an update on the support library? point b is something i didn't thought about. Thanks! – nsemeniuk Nov 22 '12 at 17:27
  • 2
    A lot of answers tell people to delete one jar but I had 2 separate library projects with their own support jars inside so I couldn't delete any, it was bugging me for ages but by applying your solution to all my library projects the jar mismatch error disappeared! Thanks so much! – AndroidNoob Jan 30 '13 at 10:15
  • 3
    Don't forget to clean you projects afterwards – Gal Bracha May 02 '13 at 09:12
  • OH! you have to do this to both the facebook SDK and your app as well. whoops. – David T. Jun 17 '13 at 09:01
  • 7
    thank you very much. For us noobs, please update your answer indicating that this has to be done on both projects. – Swapnil Luktuke Sep 18 '13 at 23:27
  • i got the same issue in my android project , so i updated the library then i got Unable to execute dex: Multiple dex files define Lcom/intel/inde/mp/android/AndroidEffectWrapper; Conversion to Dalvik format failed: Unable to execute dex: Multiple dex files define Lcom/intel/inde/mp/android/AndroidEffectWrapper; Any particular reason ?? – Mr.G Aug 01 '14 at 09:59
1

Simply delete the one in your project, remove it from the class path and try rebuild your project.

Neil
  • 448
  • 2
  • 8
1

Installing the same version of support libraries via menus mentioned in the top answer is quite a good solution.

Although this sometimes didn't work for me (I think it has something to do with my Workspace folder being synced with Dropbox, so Eclipse won't overwrite files sometimes) so the approach I am using is to link the support library from the central place.

There are these JAR files inside your SDK folder (C:\Program Files (x86)\Android\android-sdk\extras\android\ on Windows for example) which is being updated when you run SDK manager, so you could just reference that one from both the Facebook (or any other library) and your projects. Since in the end, code from JAR files gets packed to your classes.dex. You don't even need the support library in the libs folder.

Also: If you use the Gradle build system and its dependency management or even Maven you will not have problems like these, but they require more time and knowledge to set-up correctly.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Igor Čordaš
  • 5,785
  • 4
  • 42
  • 54