Friday, April 17, 2015

Adding Jar Library to Android Studio

This post will gonna show you step by step on how to add a jar library to android studio. First let's make a new project on android studio by selecting "File" then choose "New Project" as shown :
Then Specify your project name, company domain, and location for the project then click "next" :

Then choose your minimum SDK :
Choose your desired activity :
Name your activity name, layout name, etc as shown :
After this just click "Finish" button and wait until the project is ready..............
Well... By default it will be look like  picture shown below when the project it ready :
Ok... First, let's change the hierarchy view by clicking "Android" then choose "Project" as shown below :
After that expand your "App" folder, so you can see a "libs" folder in it :
We will gonna put all of our libraries inside that "libs" folder. So choose your own jar librari then put it to "libs" folder. In this project I'm using gson-2.2.4.jar :
Just copy all of those jars then paste it to "libs" folder as shown below :
Next..., open the build.gradle file inside of app folder by just double click it, then add this code "compile files('gson-2.2.4.jar')" to dependencies curly bracket :

Yaaapzz... Rightnow our jars are ready to be used in our project. So.... go to mainActivity.....click "Sync" first :

Then call a class from out jar librari, for example as shown below :
When we run the project and see the log chat :

Sooo we can see that we have succesfully included our gson-2.2.4.jar to our android studio project...

That's all of it.... I hope these simple steps are useful for you....Thanks... :-)

No comments:

Post a Comment