Jader Dias
Jader Dias

Reputation: 90593

How to add libraries to an Android project?

I would like to use Apache Commons Lang in my Android project, but I don't know how to do it. Should I use the source or the binary? How to proceed then in Eclipse?

Upvotes: 1

Views: 7938

Answers (2)

Dammy Akinsiku
Dammy Akinsiku

Reputation: 59

Personally, I'd go with the binary.

Download the binary (commons-lang3-3.0-beta-bin.zip)

Extract the jar file to somewhere you are familiar with. Usually i'd have all ma java libraries in one folder (commons-lang3-3.0-beta.jar)

Right click on your project in Eclipse -> build path -> add external archives

navigate to the location you saved the extracted the jar and select it..

Viola.. Thats it.. I hope it helps.

Happy Coding..!!

Upvotes: 1

CommonsWare
CommonsWare

Reputation: 1007604

Should I use the source or the binary?

Yes. :-)

In other words, either should be fine. Source has the advantage of allowing you to trim out stuff you don't want and fix any compatibility issues you encounter with Android. OTOH, the JAR is more convenient.

How to proceed then in Eclipse?

If you are using source, just add it to your project.

If you are using the JAR, add it to the libs/ directory of your project, then add it to your build path. Be sure to use the Add JARs button in the Build Path dialog in Eclipse to refer to the JAR that is already in your libs/ directory. Everything else will be taken care of for you.

Upvotes: 7

Related Questions