14

Hay, how do i import org.apache.commons packages into android so i can use them in my applications?

Thanks

dotty
  • 40,405
  • 66
  • 150
  • 195
  • See [this related question](http://stackoverflow.com/questions/2047706/apache-commons-codec-with-android-could-not-find-method/8287154) if you run into NoSuchMethodError at runtime. – tstaylor7 Nov 02 '14 at 06:33

4 Answers4

14

If you're using eclipse:

  1. Download jar packages for libraries you are interested in
  2. Go to project properties in eclipse -> Java Build Path -> Libraries. Add External JARs here.
Nikola Smiljanić
  • 26,745
  • 6
  • 48
  • 60
5

Just for completeness' sake - if you aren't using eclipse to develop and you are building with ant - just put the jar in your libs folder of your project.
Done!

MattK
  • 1,521
  • 1
  • 12
  • 25
3

Also, be warned that not all of them can be automatically converted to Dalvik. For example commons-httpclient does not convert cleanly from the release binaries, you need to go through source to make it work.

Zds
  • 4,311
  • 2
  • 24
  • 28
0

If you are using android Stuido - that doesn't yet supports adding libraries - you need to edit the src/build.gradle

I wanted to add org.apache.commons.net and My file called 'org.apache.commons.net.jar' was placed in the libs folder, so my build.gradles dependencies look now like this:

dependencies {
    compile files('libs/android-support-v4.jar')
    compile files('libs/org.apache.commons.net.jar')
}
lucidbrot
  • 5,378
  • 3
  • 39
  • 68