Saturday, April 11, 2015

[Android Studio] How to add an external jar into project


How to Add an External Jar in Android Studio

Any beginners of Android Studio may encounter this problem: how to add an external jar into current project. It's pretty easy, just follow these steps:

-1. download the jar file and create sub dir "libs" in the "app"dir if there's no such subdir, then put the jar file into this dir

-2. Right click current project, and select "Open Module Settings"

-3. Click "+" at the left-top corner to "Import .JAR or .AAR package"

-4. Then find and select the jar file which is now located in the "libs" sub dir. You can choose to "Remove original file" to keep the project clean.

-5. After that, android studio will automatically start to sync the whole project.

That's it, you will find out the new jar was added in your project, and also a new "build.gradle" file was also created, the new jar was added into current project's "build.gradle" file as well.