Reputation: 283
I'm trying to use a jar file in an android application on the linux command line. I've read: Android include .jar in ant compilation Which is the same thing but never got a working answer. Tried this: How to add external jar libraries to an android project from the command line but it didn't work, still gave the same error message. The error is:
-compile:
[javac] Compiling 4 source files to /home/bianca/Documents/sem12012/FIT3140 /code/jackson-example/bin/classes
[javac] messagemain.java:4: package org.codehaus.jackson.map does not exist
[javac] import org.codehaus.jackson.map.ObjectMapper;
[javac] ^
[javac] messagemain.java:21: cannot find symbol
[javac] symbol : class ObjectMapper
[javac] location: class messagemain
[javac] ObjectMapper mapper = new ObjectMapper();
[javac] ^
[javac] messagemain.java:21: cannot find symbol
[javac] symbol : class ObjectMapper
[javac] location: class messagemain
[javac] ObjectMapper mapper = new ObjectMapper();
[javac] ^
[javac] 3 errors
BUILD FAILED
/home/bianca/Downloads/android-sdk-linux/tools/ant/build.xml:602: The following error occurred while executing this line:
/home/bianca/Downloads/android-sdk-linux/tools/ant/build.xml:622: Compile failed; see the compiler error output for details.
So I'm guessing it's a problem with importing the jar. I have the jar stored in ./lib.
EDIT: I put the jar in libs according to a suggestion in an answer, it gives the same error. ant.properties is all comments, local.properties and project.properties have not been changed from the automatically generated one. build.xml has not been changed, it's just the automatically generated one.
Upvotes: 2
Views: 1787
Reputation: 4262
When building using Eclipse "run", you can have imported JARs even in subfolders of the libs folder - you can, for example, have it in libs/somefodler/somJar.jar. The Ant script shipped with the SDK, however, expects it directly in the libs folder, and not a subfolder.
Upvotes: 0
Reputation: 1006614
Use libs/
, not lib/
. The JAR will automatically be included as part of the compile process, and the JAR's contents will be packaged into your APK.
Upvotes: 3