129

I am trying to create 2 versions of an Android app (free/paid). I have an Android Library that contains files common to both. I created a new Android project and am trying to use the Library but get the error below:

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.
Versions found are:
Path: /Users/Zaheer/Developer/App Free/libs/android-support-v4.jar
    Length: 349252
    SHA-1: 612846c9857077a039b533718f72db3bc041d389
Path: /Users/Zaheer/Developer/App Library/libs/android-support-v4.jar
    Length: 337562
    SHA-1: 27c24d26e4c5d57976e6926367985548678e913c

Any ideas on how to resolve this? I've been playing with the build path to no success.

Zaheer
  • 2,794
  • 5
  • 28
  • 33

14 Answers14

177

Any ideas on how to resolve this?

Delete one.

I've been playing with the build path to no success.

Step #1: Undo all that. If you are messing with the build path, on R16 or higher version of the ADT plugin for Eclipse, you're doing it wrong.

Step #2: Pick one of those two versions of the JAR, or pick the one from the "extras" area of your SDK installation.

Step #3: Put the right JAR in App Library.

Step #4: Delete the one from App Free, since it will pick up that JAR from App Library.

You are welcome to instead have the same actual JAR file in both spots (App Free and App Library), though that just takes up extra space for no reason.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • 1
    @Necronet: Have all use the same JAR. For example, copy the latest one into each of those projects. – CommonsWare Mar 01 '13 at 13:41
  • @CommonsWare: how to know which one is the latest? – Mehul Joisar Apr 23 '13 at 10:08
  • 2
    @MehulJoisar: That's up to the authors of the JAR. In the case of the `android-support-v4.jar`, the latest one is the one in your SDK installation. – CommonsWare Apr 23 '13 at 10:55
  • @CommonsWare: Actually,I was trying to use `ActionBarSherLock` created by `JakeWharton` and `SlidingMenu ` created by `jfeinstein10` at same time inside my application project.now which one should I delete ? right now I have copied `android-support-v4.jar` of `ActionBarSherLock` and pasted it inside libs folder of `SlidingMenu` and `MyApplication`.everything works fine.is this right way or should i change? – Mehul Joisar Apr 23 '13 at 11:04
  • 5
    @MehulJoisar: I can't answer that. I usually take the latest `android-support-v4.jar` from the SDK and copy it into all of the library projects (plus delete the one from the SDK). – CommonsWare Apr 23 '13 at 11:12
  • Is the Android V4 JAR file should only be one at the "parent" libs folder or only put at the libs folder under main Android project folder itself? – David Dimalanta Aug 27 '13 at 03:10
  • @DavidDimalanta: I have no idea what you mean, sorry. Consider asking a fresh SO question, where you can provide more details regarding your concept of "parent libs folder" as compared to "libs folder under main Android project folder". – CommonsWare Aug 27 '13 at 10:50
  • 1
    I just had this problem, but it seemed to come completely out of the blue, as several other (more difficult) Eclipse/Android problems have. This answer fixes the effect but apparently not the cause. – Joe Lapp Nov 04 '14 at 16:56
24
  1. Delete android-support-v4.jar from App Free
  2. Add the same file from App Library to App Free
Lee Chun Hoe
  • 728
  • 11
  • 19
  • @Lee Chun Hoe can you tell me how to go to this path in MAC OS. I want to delete android-support-v4.jar. – Rakesh Apr 01 '15 at 03:28
  • @Rakesh In Eclipse Package Explorer, expand your project, under libs folder, delete that android-support-v4.jar file. – Lee Chun Hoe Apr 22 '15 at 14:05
12

Above solutions mostly solve the problem. after using these solutions and problem persists. Then

GO to project folder -> libs-> and delete "android-support-v4.jar"

Hoping it would solve your problem as it solved my problem.

Nauman Khalid
  • 852
  • 9
  • 15
11

There are some scenarios where you have multiple library projects having the the android-support-v4.jar in their libs and build paths and your project has a dependency towards both of them. Say for example in my case I have the following library projects in my workspace,

  • libfacebook
  • libsherlockactionbar

Both these projects are independent and my project.properties looks like the following,

# Project target.
target=android-17
android.library.reference.1=../libfacebook
android.library.reference.2=../libsherlockactionbar

When I build my project, I get a jar mismatch problem having duplicate references to two copies of the same file. What I did to solve this issue is a bit of trickery. I created a new library project named libcommons as a parent to all the other library projects in my workspace, including libfacebook and libsherlockactionbar. Then I removed the support library from all other projects and kept only one copy inside libcommons's libs folder. Then I have added libcommons as a reference to all my other library projects. Once cleaned my workspace, everything works like a charm.

C--
  • 16,393
  • 6
  • 53
  • 60
8

This is a more elegant fix than deleting and adding files!

You just need to :

  1. Right Click the project App Free
  2. Go To "Android Tools" > "Add Support Library"
  3. Approve the permissions and let it update the library
  4. Repeat this process for the project App Library

The Android Support Library will then be in sync (:

cokeby190
  • 609
  • 7
  • 14
7

VERY SIMPLE SOLUTION

A very simple solution worked for my case, just copy the same (android-support-v4.jar) jar file to all the projects. There will be no more conflict.

1 Copy the jar file android-support-v4.jar from libs folder of any one project.

2 Delete the jar file android-support-v4.jar from second project's libs folder which is already existing.

3 Paste the newly copied jar file of first project to libs folder of second project.

The jar mismatch issue will be resolved by now.

gprathour
  • 14,813
  • 5
  • 66
  • 90
5

Just copy the library from one of the projects to the other one. Maybe the timestamp needs to be the same on both.

Rafael Sanches
  • 1,823
  • 21
  • 28
4

Resolution:

  1. Right click on 'free' project > Android Tools > Add Support Library.
  2. Do the same thing on 'paid' project.
  3. Clean all projects
Dr.Kameleon
  • 22,532
  • 20
  • 115
  • 223
2

Check if there are irrelevant projects open for you, because that was the case for me, it seemed one of the JAR files was related to a different project, which I wasn't working with, so I just closed that project, did a clean build of the project I'm working on and didn't have the problem anymore! Hope this helps someone!

Arturas M
  • 4,120
  • 18
  • 50
  • 80
1

Use same jar while adding external jars in both library and project

1

well.. it works for me:

Go to

Project folder > libs

then, delete "android-support-v4.jar"

Then

project > Clean

It will work!

Bhushan Kawadkar
  • 28,279
  • 5
  • 35
  • 57
1

I just had this issue, but instead of deleting the conflicting android-support-v4.jar I just renamed it to android-support-v4_PROJECT.jar, which removed the conflict.

If you are wondering how to rename a file in Eclipse, you just need to highlight the file and press F2.

eBehbahani
  • 1,579
  • 5
  • 19
  • 41
0

You just need to have exactly the same android-support-v4.jar checksum on each of your projects. For this, you can copy/past one of them in all of your conflicting projects / library.

Nothing else to do, clean and enjoy :)

tryp
  • 1,120
  • 20
  • 26
0

May be you open 2 project same time (both using android-support-v4.jar) . I close 1 project and every thing ok

Wolf
  • 6,361
  • 2
  • 28
  • 25