tags:

views:

76

answers:

2

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?

A: 

At compiling do this:

javac -encoding ascii -target 1.5 -d bin/classes \
-bootclasspath $SDKDIR/android.jar src/some/project/* -classpath=libs/*.jar

And, when you are generating the bytecode for Dalvik:

dx --dex --output=bin/classes.dex bin/classes libs/*.jar

Also, when you are packaging the APK file:

apkbuilder bin/something.apk -z bin/projectname.ap_ \
-f bin/classes.dex -rf src -rj libs

I'm assuming you are using Linux... on Windows will be almost the same.

Cristian
+1  A: 

Answering my own question:

I created a file "build.properties" and added the line

external.libs.dir=lib

It was a lucky guess, really.

Jay K