Sunday, December 29, 2013

Android Studio: How to refer an external library (.jar)

I had quite a bit of trouble doing this, hence thought of blogging it.

First you need to download the required .jar file. In my case it is 'commons-codec-1.9.jar'.

Then create a folder named 'lib' in your project folder and copy the .jar file.

From Android Studio, right click the lib file and select 'Add as Library...'.



Select your project and confirm.


Open 'build.gradle' of your project and add line 'the following line under 'dependencies':
compile files('libs/commons-codec-1.9.jar')



Add code to use the referenced library.



Rebuild your project.



That's it! :)

No comments:

Post a Comment

Touchpad not working on CloudReady / Chrome OS? Here's how to fix it!

Covid-19 break seems to be opening up interesting avenues for me. I started a storeroom cleanup activity and I found an old laptop which I s...