Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add external jar libraries to an android project from the command line

Tags:

android

jar

ant

I'm trying to build an Android project that has some dependencies. The jar files are in the lib/ directory. I can build the project by adding those jar file to my classpath, but of course it Force Closes in the emulator because those libraries aren't present.

I'm doing this from the command line with ant (not in eclipse). How can I make it include those libraries in the apk from the command line?

like image 485
Jay K Avatar asked Jul 10 '10 02:07

Jay K


People also ask

How can I use external jars in an Android project?

Add your jar file to the folder app/libs . Then right click the jar file and click "add as library". You can then expand your Project to find the "libs" folder or right click your project and make a new directory. You can then move the JAR file for your library into that directory using your OS file manager.

Where is JAR file in Android project?

If you are unable to find the libs folder in Android studio then open your android project in “Project” mode If the project is already opened in the “Android” mode. Then go to Your Project Name > app > libs and right-click on it and paste the downloaded JAR files.

How do I add an external library to Intellij?

From the main menu, select File | Project Structure | Project Settings | Modules. Select the module for which you want to add a library and click Dependencies. button and select Library. In the dialog that opens, select a project or a global library that you want to add to the module.


1 Answers

Jay K's answer was right at the time of writing, but now the SDK has changed, and here is the new way to do it:

Add the following line to ant.properties:

jar.libs.dir=lib 

Tested, works where external.libs.dir does not work.
That changed in December 2010 and then again in October 2011.

like image 117
Nicolas Raoul Avatar answered Sep 20 '22 17:09

Nicolas Raoul