Home » Android » android – Difference between module, libraries, jar, library projects, gradle projects, aar and jar

android – Difference between module, libraries, jar, library projects, gradle projects, aar and jar

Posted by: admin June 15, 2020 Leave a comment

Questions:

I work for a company which has a android mobile application developed by an offshore team. I have access to GitHub repositories.

I am piecing together the android app block by block and it is giving me hell.

How do I distinguish between module, libraries, jar, library projects, gradle projects, aar and jar. Can someone please give me a practical definition. NOT out of a freaking google search. I have Google too.

PS yes I am a noob and not proud of it.

How to&Answers:

I’m just giving a brief description about each of these. I hope I’m clear.

Module : A Module is an component of your application that can build / test independently and re use it in another application if required.

Libraries : AAR files, JAR files etc.

JAR : Java library

AAR : Just like JAR, only difference is that it also contains android specific files like resources etc.

Gradle Project : Gradle is just a build system which is used by Android Studio to build the android project. Its very much powerful as compared to the build system which was used in Eclipse earlier.

Library Project : An Android library project is similar to an Android app project in that it also includes a project manifest file in the project’s root directory. Also, this directory contains src, res, and other directories that you also find when building an app project.
However, there is a significant difference. You cannot compile a library project into an APK file because a library project doesn’t describe an app. Instead, it provides reusable code and resources that contribute to an app when the app’s project and source code refer to the library project. At build time, this code and these resources are merged into the app’s APK file.

To explain more on this, let me give you an example :
Say you want to use a networking library volley for making API calls, now since this is an open source library from Google you can clone it making customisations as per your requirement.

You can make volley library as your Library Project, build it independently, unit test, etc.

Now say you started building an application where you need to make HTTP calls so you need to add volley library to your project. You have two choices for that :

  1. Compile your library project volley, generate the aar file and add it your app Project.

  2. Add Volley as module in your project. (If you choose this option you can make changes to volley library in same studio project since it will act as a component in your project)

Please let me know if something is not clear.

Answer:

1.) Module

A module is a collection of source files and build settings that allow you to divide your project into discrete units of functionality. Your project can have one or many modules and one module may use another module as a dependency. Each module can be independently built, tested, and debugged.

There are 4 type of module in Android Studio.

  • Phone & Table Module
  • Android Wear Module
  • Android TV Module
  • Glass Module

2.) Support Library

The Android Support Library offers a number of features that are not built into the framework. These libraries offer backward-compatible versions of new features, provide useful UI elements that are not included in the framework, and provide a range of utilities that apps can draw on.

Support libraries provide a range of different features:

3.) Jar file

JarFile is used to read jar entries and their associated data from jar files.

for more detail visit this : https://developer.android.com/reference/java/util/jar/JarFile.html

4.) Android Library Project

The Android team introduced a new binary distribution format called Android ARchive(AAR). The .aar bundle is the binary distribution of an Android Library Project.

An AAR is similar to a JAR file, but it can contain resources as well as compiled byte-code. This allows that an AAR file is included in the build process of an Android application similar to a JAR file

5.) Gradle and Gradle Project

Gradle is an automated build toolkit that allows the way in which projects are built to be configured and managed through a set of build configuration files. This includes defining how a project is to be built, what dependencies need to be fulfilled for the project to build successfully and what the end result (or results) of the build process should be. The strength of Gradle lies in the flexibility that it provides to the developer. The Gradle system is a self-contained, command-line based environment that can be integrated into other environments through the use of plug-ins. In the case of Android Studio, Gradle integration is provided through the appropriately named Android Studio Plug-in.

for more detail visit this : http://www.techotopia.com/index.php/An_Overview_of_Gradle_in_Android_Studio