34
votes

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

3

3 Answers

122
votes

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!

1
votes

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

1
votes

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.