Wednesday, October 5, 2016

Library (jar) creation with androidstudio

There are two way in android to create library project first use project with whole source code with plugin type library in gradle and second create jar file.

Both type has their different uses regarding application requirement.
In eclipse it is very simple just check islibrary project option in add library section and you can generate library project but for android studio it is different way to create library project.

Here is the steps to create jar file using android studio and also same project can be added as a library module without generating jar .


1) Create a project.

2) open file build.gradel of module level

3) change one line in build.gradel module level:
apply plugin: 'com.android.application' -> apply plugin: 'com.android.library'

4) remove applicationId in the module level build.gradel file .

applicationId "com.mycomp.testproject"

5) build project
Build > ReBuild Project

6) then you can get aar file
app > build > outputs > aar folder

7) change aar file extension name into zip

8) unzip, and you can see classes.jar in the folder.
rename with your library name with this jar and use it!