Vamsi Challa
Vamsi Challa

Reputation: 11109

How to add external libraries to my application in android

I have an application that I have to look at as a training exercise. It has used few external libraries such as SlidingMenu, ImageViewZoom and ActionbarSherlock.

I have downloaded and extracted those libraries but I have no idea how to add them to my existing project.

Upvotes: 1

Views: 12462

Answers (4)

JNI_OnLoad
JNI_OnLoad

Reputation: 5442

You need to import those libraries as Android Project from existing source and mark them as "Is Library" by going into their properties.

Once you marked it as "Is Library" add it to your project by going into Properties->Android->Library->Add (it will show the list of library you imported).

Upvotes: 3

Abhijit Chakra
Abhijit Chakra

Reputation: 3236

if they are jars the make a libs folder then paste the jar in it and then go to your project buildpath->configure build path->Add Jars-> ok and if it is a library project then go to your project Property->Android->Add(Your Lib Project)->Ok->Apply

Upvotes: 0

Emil Adz
Emil Adz

Reputation: 41099

The Right Way:

What you need to do is to copy the external library (JAR file) to the /libs folder of your project.

That way those libraries will compile with your project and could be use on real device when you deploy your application.

Some times you will need to add a project to your workspace ( For example the Google Map library) and then add the library reference using the properites -> Android window at the bottom.

You can get an idea of how it's done by reading the first 3 step of this Google Map API V2 guide I wrote. there I reference the android library project:

Google Map API V2 Guide

The Wrong Way:

any other way, like for example adding the files using the properties - > Java build path screen may result in a missing library when you run the project on a real device.

Upvotes: 1

CommonsWare
CommonsWare

Reputation: 1006539

For those that are distributed as a simple JAR, do what Emil Adz indicates, and copy that JAR into your project's libs/ directory.

For those, like ActionBarSherlock, that are distribute as Android library projects, you will need to do a bit more work. In the case of Eclipse, you will need to import the library project into your workspace, then go into Project > Properties > Android for your application project and click the [Add] button to add the library project to the application project. For a command-line build, use android update lib-project to link the application and library project together.

You can read more about referencing an Android library project from Eclipse or the command line in the documentation.

Upvotes: 4

Related Questions