Android+Ant external jar library

1.2k views Asked by At

I'd like to try org.apache.commons.lang.StringUtils in my Android project. I have downloaded commons-lang3-3.1.jar and placed it in my project's libs directory. However importing it fails with the library not being found. I have used many variations of

import org.apache.commons.lang.StringUtils;

with no success. My environment is the linux console and I'm using ant to compile, no Eclipse. My understanding is that Ant picks up any library in the project libs directory.

Please help. Android/java coding noob.

2

There are 2 answers

0
HandlerExploit On BEST ANSWER

Lang 3.0 (and subsequent versions) use a different package (org.apache.commons.lang3) than the previous versions (org.apache.commons.lang), allowing it to be used at the same time as an earlier version. ref: http://commons.apache.org/lang/

import org.apache.commons.lang3.StringUtils;
2
Yusuf X On

Just put the jars in the libs/ directory. Silly me, I was putting them in the lib/ directory until I ran into the same issue and found the answer here: How to build an android app with external libraries using ant?