9

I am new to Android Programming. I am using Eclipse as the IDE for development. I have started a new project and some jar files were automatically added to the project. Could you explain what each of these jar files mean?

  • Android 4.4.2
    • android.jar
  • Android Private Libraries
    • android-support-v7-appcompat.jar
    • android-support-v4.jar
  • Android Dependencies
    • appcompat_v7_2.jar
  • libs
    • android-support-v4.jar

Also, apart from these, there is a folder generated named "appcompat_v7_2" which can be seen in the Project Explorer. It also contains Android Private Libraries and libs folder.

I feel that there is some sort of redundancy involved here. Do clear the confusion.

nnori
  • 127
  • 2
  • 14
  • 1
    http://stackoverflow.com/questions/22261288/why-eclipse-automatically-adds-appcompat-v7-library-support-whenever-i-create-a – Sree Jun 03 '14 at 06:22
  • I understand that support library is helpful for backwards compatibility. But what I do not understand is the creation of so many jar files and the role each jar file. – nnori Jun 03 '14 at 06:28
  • http://devmaze.wordpress.com/2011/05/22/android-application-android-libraries-and-jar-libraries/ – Sree Jun 03 '14 at 06:30

2 Answers2

6
  • Android 4.4.2
    • android.jar

This is the native API library for Android 4.4 (if you go to Android Package Manager, you can see many files ranging from Android 2.* - Android 4.*)

So, when you create a new project in Eclipse, it will automatically use that library which was specified in the property for Android API level.

  • Android Private Libraries
    • android-support-v7-appcompat.jar
    • android_support-v4

These are the support libraries used for your application when it is run on lower Android versions. For example if you are using Android API 19 as the targeted library to compile, you will need the android_support-v4 library the application is to run on lower Android API devices.

The difference between v7 and v4 is that v7 supports Android v3.0 and above and v4 supports Android v2.0 and above.

I feel that there is some sort of redundancy involved here.

The Android Private Libraries and the Android Dependencies are not actual folders. They are created by Eclipse for user convenience.

When the project is created, the support libraries for both v4 and v7 are created in the appcompat_v7_x/libs folder.

Android Private Libraries just has references to the support libraries. And Android Dependencies tells us which appcompat_v7_x the project referencing or using.

If you look at the icon in the Eclipse, libs icon and Android Private Libraries are different icons. It is because Android Private Libraries is not an actual folder. You do not find it on the disk.

So, there isn't any redundancy, in the sense that no files are being copied or duplicated.

Enjoy your Android development! :) Try Android Studio, it is way better than Eclipse!!

nnori
  • 127
  • 2
  • 14
Tim
  • 3,755
  • 3
  • 36
  • 57
  • 2
    That was a helpful answer. But, it does not clear my confusion regarding the generation of so many jar files. Wouldn't three jar files be sufficient? One for the native Android API, and two for the support libraries? – nnori Jun 03 '14 at 06:48
  • I understand it like this. After each project is created, the necessary support libraries are created in the appcompat_v7_x/libs folder. And the project just references them via Android Private Libraries. That is, copies of the jar files are not created in the project folder. The files that we see in the Android Private Libraries folder are just references to the Java ARchives in appcompat_v7_x/libs folder. Am I right? – nnori Jun 03 '14 at 07:22
  • 1
    Yup! you are right! you can proof your answer by checking your project directory! you will not be able to find the Android Private Libraries, you only able to see libs folder! – Tim Jun 03 '14 at 07:34
  • @Tim, Then what happens when we manually right click the jars in the lib folder and do "Build Path: Add to Build Path"? Isn't there redundancy then since now they are referenced **twice**? – Pacerier Nov 14 '14 at 07:26
  • @Pacerier yup! you could try it yourself, and "Add to Build Path" then you open the project directory and go to build path, you could see the new extra library, but that library has already been reference! try to migrate to Android Studio, you would love it, they have Gradle build system which is way better than Eclipse, and it is a lot less messy! :) – Tim Nov 14 '14 at 07:59
  • @Tim, So is it referenced **twice** or not? Is twice the amount of memory consumed? Or does it only appear so? What about conflicts? – Pacerier Nov 14 '14 at 08:31
  • @Pacerier yes, it is referenced twice, you can check it in your /bin/dexedLibs folder, you could see 2 same .jar, so about memory space, just answer, for conflicts, it doesnt matter, cuz the compiler will randomly assign which .jar to use (you can google about it having 2 same .jar in a project or u can test it yourself!) – Tim Nov 14 '14 at 08:43
  • @Tim, Btw, the page https://developer.android.com/sdk/installing/studio.html states that "Android Studio is currently in beta. Some features are not yet implemented and you may encounter bugs." Why will you use a buggy problem like Android Studio? – Pacerier Nov 16 '14 at 00:07
  • @Pacerier i have used Android studio since last year, and I encounter Exlippse more bugs than Android Studio! overall, Android Studio is very stable and the IDE is really good especially the UI design, definetely your productivity will increase! give it a try! :) – Tim Nov 17 '14 at 00:36
0

These are just libraries that contain content for your application. When you do "import android.blah.blah.blah" you are getting that functionality added to your code. And to list all the library contents would be too much work.

user192198
  • 11
  • 4
  • This answer makes no attempt to deal with the specific points raised in the question. It is a trivial and lazy posting. – NickT Jun 03 '14 at 06:48