71

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
Infinite Recursion
  • 6,511
  • 28
  • 39
  • 51
SKK
  • 5,261
  • 3
  • 27
  • 39

10 Answers10

54

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.

Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
Muhannad A.Alhariri
  • 3,702
  • 4
  • 30
  • 46
  • 1
    I was able to solve the issue by adding one of the open source library as an external jar. Thanks. – SKK May 09 '13 at 07:00
48

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?

Community
  • 1
  • 1
pjco
  • 3,826
  • 25
  • 25
  • 1
    It may work! but I think the easiest way to do so is what I suggested! but your answer is still correct as you suggest – Muhannad A.Alhariri Aug 04 '13 at 06:22
  • 1
    Thanks :) And actually I'm a firm believer in whatever works. Were you able to get the javadocs working correctly though? – pjco Aug 04 '13 at 16:56
  • What happens if I have more than 3-4 Lib Project and minimum 2 of them requires the "android-support" lib? I am facing same issue. – DearDhruv Mar 27 '14 at 04:52
  • Doenst work for me. It makes things only more worse. Now all my projects are temporary destroyed oO damn :( – Martin Pfeffer Jun 06 '14 at 01:16
  • Just to add, for Windows, if an error occurs saying that the android support library folder located at: C:\\extras\android\support\\ is currently being used and it suspects the Anti Virus is at fault. You will also think that Eclipse is using the folder but it should not base on the answer provided. What I did to is just to close the folder. This occurs when the SDK Manager install the download support library. – Neon Warge Sep 26 '15 at 09:27
16

Remove android-support-v4.jar file from the libs folder from your project.

Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
7

Actionbarsherlock has the support library in it. This probably causes a conflict if the support library is also in your main project.

Remove android-support-v4.jar from your project's libs directory.

Also Remove android-support-v4.jar from your second library and then try again.

Jar Mismatch Found 2 versions of android-support-v4.jar in the dependency list

Community
  • 1
  • 1
Raghunandan
  • 132,755
  • 26
  • 225
  • 256
  • I had tried your solution. and i have mentioned it my question also. but, thanks for the reply. – SKK Apr 17 '13 at 10:03
  • @Santhosh it worked for me. I don't any see any reason why it won't work. Probably your C drive is secured and that's the reason you can't delete it. Move the sdk to another folder and give it a try. Check the folder permission and check admin permission's also – Raghunandan Apr 17 '13 at 10:05
  • I created a new workspace and its not secured. i have admin rights. and i was able to delete it, but the problem still exists. it still says JAR mismatch and if i delete support jar from any library it gives cannot be resolved to a type error. – SKK Apr 17 '13 at 10:10
  • delete the jar form your project. refer the library project ABS. Check if resources have any error .clean and build. This should work. http://stackoverflow.com/questions/16003396/import-r-cannot-be-resolved-when-i-import-actionbarsherlock/16003930#16003930 – Raghunandan Apr 17 '13 at 10:14
  • you have said it worked for you. did you follow the steps to reproduce the problem i have mentioned or you are mentioning about some other project where u added libraries.? – SKK Apr 17 '13 at 10:32
  • @Santhosh i even posted a snapshot of how to use ABS in the link in my answer. I too had a similar problem but i solved it. – Raghunandan Apr 17 '13 at 12:24
  • I checked your answer at that time itself. But, i already know about it. I can add one library without any problem. i have added ABS successfully. But when i am trying to add DVP i am facing the problem which i have mentioned. – SKK Apr 17 '13 at 12:44
  • Remove the android-support-v4.jar from dvs and give it a try. Heres' a link where i answered yesterday and the user was using two libraries. slinding menu and ABS http://stackoverflow.com/questions/16033855/actionbarsherlock-4-3-and-sliding-menu-integration/16034061#16034061. I gave the sme answer provided here and it worked for the user. – Raghunandan Apr 17 '13 at 12:45
  • Hey, I just found that the Directional View pager library is deprecated from this link http://stackoverflow.com/a/12018612/1567588 and i found a jar with some modifications to that. Now, i think i can proceed creating layout and write code. i am quiet sure that your solution works in general. In my case, It must be because of the library since it was using an old version of support revision. Am not sure either. Thanks for the support. I will upvote your answer. – SKK Apr 17 '13 at 13:05
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/28373/discussion-between-raghunandan-and-santhosh) – Raghunandan Apr 17 '13 at 13:08
5

I agree with pjco. The best way is the official method explained in Support Library Setup in the tutorial at developer.android.com.

Then, in the Eclipse "package explorer", expand your main project and delete android-support-v4.jar from the "libs" folder (as Pratik Butani suggested).

This worked for me.

Community
  • 1
  • 1
nettie
  • 628
  • 1
  • 11
  • 23
5
  1. Jar mismatch comes when you use library projects in your application and both projects are using same jar with different version so just check all library projects attached in your application. if some mismatch exist then remove it.

  2. if above process is not working then just do remove project dependency from build path and again add library projects and build the application.

Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
Gopal Sharma
  • 300
  • 4
  • 14
1

I believe you need your support package in both Library and application. However, to fix this, make sure you have same file at both locations (same checksum).

Simply copy the support-package file from one location and copy at another then clean+refresh your library/project and you should be good to go.

Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
waqaslam
  • 67,549
  • 16
  • 165
  • 178
  • As suggested, I copied the support jar from the libs folder of ABS and pasted it in DVP and my project's libs folder. restarted eclipse, cleaned, built again. now there are errors in DVP and MyApp. "The container 'Android Dependencies' references non existing library 'C:\Users\ksanthoshkumar\My_Workspace\DVP_library\bin\dvp_library.jar'" in MyApp. and "cannot be resolved to type and few more errors in DVP" – SKK Apr 17 '13 at 10:05
  • are you using the correct SDK version for your libraries and app project. Please check that. – waqaslam Apr 17 '13 at 10:10
  • yes SDK version 4.2 for all three(project and two libraries ABS and DVP) – SKK Apr 17 '13 at 10:11
  • @Santhosh whats your minsdkVersion should be 10 i guess – Raghunandan Apr 17 '13 at 10:16
  • minimum SDK is 8. I use the latest version as the targetSDK as it is recommended. see the edit in my question. – SKK Apr 17 '13 at 10:17
  • minsdk should be 10. Change it to 10 from 8 – Raghunandan Apr 17 '13 at 10:20
  • @Raghunandan: i changed it. no change. – SKK Apr 17 '13 at 10:27
1

I think you create a new workspace and import all project properly with his lib and also add external jar android-support-v4.jar in adb bundle in sdk extra files. I think its work for you. Hope all the best

And also use the android support lib it may be help you and also update your adt bundle

Pratik Butani
  • 60,504
  • 58
  • 273
  • 437
0

In my case there was another directory within my workspace, having the same jar file as the one in my project. I hadn't created that directory or anything in it. It was created by Eclipse I believe. I just erased that directory and it just runs ok.

-1

Right click on your project -> Android Tool -> Add support library