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?
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With