Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jar mismatch! Fix your dependencies

Steps to reproduce:

  1. create a android project "MyApp"
  2. import ActionBarSherlock(ABS),Directional ViewPager(DVP), or any other open source library which use android support library.
  3. Add the libraries to the project "MyApp"

Console log:

[2013-04-17 14:27:12 - MyApp] Found 2 versions of android-support-v4.jar in the dependency list, [2013-04-17 14:27:12 - MyApp] but not all the versions are identical (check is based on SHA-1 only at this time). [2013-04-17 14:27:12 - MyApp] All versions of the libraries must be the same at this time. [2013-04-17 14:27:12 - MyApp] Versions found are: [2013-04-17 14:27:12 - MyApp] Path: C:\Users\santhosh\My_Workspace\DVP_library\libs\android-support-v4.jar [2013-04-17 14:27:12 - MyApp]   Length: 140011 [2013-04-17 14:27:12 - MyApp]   SHA-1: fc834ac8147bc4ed0b555f90f500a57d4232c448 [2013-04-17 14:27:12 - MyApp] Path: C:\Users\santhosh\My_Workspace\abs_library\libs\android-support-v4.jar [2013-04-17 14:27:12 - MyApp]   Length: 271754 [2013-04-17 14:27:12 - MyApp]   SHA-1: 53307dc2bd2b69fd5533458ee11885f55807de4b [2013-04-17 14:27:12 - MyApp] Jar mismatch! Fix your dependencies 

I know i am suppose to delete android-support-v4.jar from libs folder and keep only one copy for all. But, that is not solving my problem.

When i try to delete the android-support-v4.jar from MyApp, it gives me the following error.

 Problems encountered while deleting resources.  Could not delete 'C:\Users\santhosh\My_Workspace\MyApp\libs\android-support-v4.jar'. 

When I try to delete the android-support-v4.jar from ABS, it gives me the following error

 ????? cannot be resolved to a type error. 

I have tried to clean the project, Fix Project Properties. Restart eclipse, Build, import and add again. I have tried to copy the support jar in libs folder from one library to other. delete the support jar in both libraries and add it to the MyApp project. Nothing has worked for me.

if i try to add single library, it works fine. i am facing the problem when trying to add 2 or more libraries to a single project.

error getting when I add two libraries in MyApp:

The project was not built since its build path is incomplete.  Cannot find the class file for android.support.v4.app.FragmentActivity.  Fix the build path then try building this project MyApp Unknown Java Problem The type android.support.v4.app.FragmentActivity cannot be resolved. It is indirectly referenced from required .class files MyActivity.java/MyApp/src/com/santhosh/myapp    line 10 Java Problem Jar mismatch! Fix your dependencies MyApp Unknown Android Dependency Problem 
like image 275
SKK Avatar asked Apr 17 '13 09:04

SKK


People also ask

How do you get dependencies of a jar?

jar file. Use the -verbose:class option to find class-level dependencies or use the -v or -verbose option to include dependencies from the same JAR file. Use the -R or -recursive option to analyze the transitive dependencies of the com.

What is dependency jar?

a dependency management utility for jar files. It's primary purpose is to traverse through a directory, parse each of the jar files in that directory, and identify the dependencies between the jar files. The output is an xml file representing the PhysicalDependencies between the jar files.


2 Answers

Don't Include the android-support-v4 in the library , instead you can add it to your project as an external jar using build path menu > add external jar

Sometimes you have to clean your project.

like image 146
Muhannad A.Alhariri Avatar answered Oct 09 '22 16:10

Muhannad A.Alhariri


Use a Library Project just for the Support Library

As of ADT 22, using Eclipse Juno

I don't think any of the above are really the best answers. I also don't think it is recommended to use the external jar function in Eclipse anymore (AFAIK).

Rather, what worked for me is to create a separate empty library project.

Then use Android tools > Add Support Library to get the latest version you need or want.

Then remove the support lib jar from all other projects.

Finally, for every project that requires it, add a reference to your new Library project

(project properties) > Android > (Library box) > Add...

Then all your projects will have a single source to use and update the support library. This also makes javadocs easier to get working.

For info on how to setup the javadocs see:

How to attach javadoc or sources to jars in libs folder?

like image 41
pjco Avatar answered Oct 09 '22 17:10

pjco