1

My sdk folder is having two android-support-v4.jar files : /sdk/extras/android/support/v7/appcompat/libs/android-support-v4.jar /sdk/extras/android/support/v4/android-support-v4.jar

Just to keep things clean, i want to remove one of these duplicate libraries. Which do you think is the safest one to remove and why?

Note : In case this info helps - I was using the ADT bundle earlier(which had Eclipse Juno i think ), now i am using the latest Eclipse Luna(downloaded from eclipse.org) with the latest ADT plugin(installed from https://dl-ssl.google.com/android/eclipse) and the latest support library downloaded using the sdk manager.

faizal
  • 3,497
  • 7
  • 37
  • 62
  • 3
    "Just to keep things clean, i want to remove one of these duplicate libraries" -- neither of those are yours. They will simply be put back there the next time you update the Android Support library from the SDK Manager. I suggest leaving them alone, unless you are running into some specific problem. – CommonsWare Jul 07 '14 at 11:50
  • Why would you want to remove the libraries? They are not duplicates, they are support libraries for API Level 4 amd API Level 7 respectively – cokeby190 Jul 07 '14 at 11:55
  • @cokeby190 Are you sure both the `android-support-v4.jar` are not duplicates? They have the exact same size. – faizal Jul 07 '14 at 11:57
  • @CommonsWare do you think there is a case when Eclipse/project will opt to take the v4 jar from the v4 folder instead of from the v7 folder? I am just trying to understand whether v4 jar in the v4 folder will be used at all, since the v4 jar is anyway present in the v7 folder. – faizal Jul 07 '14 at 12:03
  • Even if they are the same, but you shouldnt be modifying any file in the SDK at all, it will break future projects you might be building on the support libraries. There is no need to clean up anything in the SDK folders. – cokeby190 Jul 07 '14 at 12:05
  • @cokeby190 why would any future projects break ? My understanding is that any new projects i create would always take the v4 jar from the v7 folder. Do you think otherwise? – faizal Jul 07 '14 at 12:09
  • I think Ved Prakash answered your question. In any case, i dont understand why you would want to modify the v4 folder. Its only 2.5MB total in size. I dont think leaving it as it is will cause any damage on its own, but I guess, each to its own. – cokeby190 Jul 07 '14 at 12:13
  • @cokeby190 you can blame my OCD :) – faizal Jul 07 '14 at 12:14
  • Hahaha! I would just leave it. But its entirely up to you ;) – cokeby190 Jul 07 '14 at 12:23
  • "do you think there is a case when Eclipse/project will opt to take the v4 jar from the v4 folder instead of from the v7 folder?" -- no. – CommonsWare Jul 07 '14 at 22:33

2 Answers2

3

Don't remove it. V7 includes the support library and adds additional features (such as ActionBar). The entire folder will be added to any project created with Eclipse wizard that requires these features, so it needs to have android-support-v4.jar inside.

David Ferrand
  • 5,357
  • 1
  • 33
  • 43
  • ok i don't remove the v4 that is inside v7. But any reason to keep the other v4? – faizal Jul 07 '14 at 11:55
  • Yes. Other apps that don't need the extra features from V7 will use only the standalone V4 jar. – David Ferrand Jul 07 '14 at 11:56
  • But the standalone v4 jar is present in the v7 folder as well. So do you think that such projects will take the v4 jar from the v4 folder instead of the v7 folder? – faizal Jul 07 '14 at 11:59
  • No they won't. It's true that it's a duplicate, but that's how the SDK is designed. And you shouldn't modify the SDK content without using the SDK Manager: you'll break it. – David Ferrand Jul 07 '14 at 12:02
  • ok. So that means the v4 jar inside the v4 folder would never actually be used by any new projects that i create, no matter what min sdk i set? i.e. only the v4 jar from the v7 folder would be used always? – faizal Jul 07 '14 at 12:05
  • 1
    It depends, sometimes new projects need V4 (for example a project with the DrawerLayout). In case of "conflict", you can see this message in the log: `WARNING: Found both android-support-v4 and android-support-v7 in the dependency list. Because v7 includes v4, using only v7.` So you get your confirmation that Android handles the build properly ;) – David Ferrand Jul 07 '14 at 12:14
1

Which do you think is the safest one to remove and why?

  • /sdk/extras/android/support/v4/android-support-v4.jar

v4 Support Library

This library is designed to be used with Android 1.6 (API level 4) and higher. It includes the largest set of APIs compared to the other libraries, including support for application components, user interface features, accessibility, data handling, network connectivity, and programming utilities. So that you will able to make your application backword compatible.

v7 Libraries

There are several libraries designed to be used with Android 2.1 (API level 7) and higher. These libraries provide specific feature sets and can be included in your application independently from each other.

v7 appcompat library

This library adds support for the Action Bar user interface design pattern.

Note:
This library depends on the v4 Support Library. If you are using Ant or Eclipse, make sure you include the v4 Support Library as part of this library's classpath.

So yes you need both jars if you want to use v7.

The following SO post illustrates the same difference-between-android-support-v7-appcompat-and-android-support-v4.

Read more about Support Library Features.

UPDATE:

To be not more confused lets elaborate the point -

So that means the v4 jar inside the v4 folder would never actually be used by any new projects that i create, no matter what min sdk i set? i.e. only the v4 jar from the v7 folder would be used always?

  • RIGHT v7 includes the v4 support library so there is no need to have it in there again if you look in the libs folder of the v7 support library you will see that the v4 jar is already referenced in the library.
Community
  • 1
  • 1
sjain
  • 23,126
  • 28
  • 107
  • 185
  • That makes me wonder what exactly is the purpose of the v4 jar in the v4 folder, if it will never be used. – faizal Jul 07 '14 at 12:13
  • @faizal - If you look in the SDK where the support libraries are you will see that v7 contains the v4 jar file so when you import v7 you have the v4 too. Don't include both. Yes that makes sense what you thought. – sjain Jul 07 '14 at 12:19
  • @faizal - So if you are using v7 then just use it. Updated the answer also. :) – sjain Jul 07 '14 at 12:21