Use open source library for Android project in Eclipse

The ideal way is to add the open-source library as a project in Eclipse, then include this project in the Android project's build path.  In this case, one can dive into the source easily for debugging.

Unfortunately, some open source libraries do not build well in Eclipse together with Android projects.  The other way is using libraries’ jar files.  The supposedly good way is adding the jar files to folder libs of the Android project, but it would make incorporating JavaDoc and source code difficult (why this is the case is puzzling).  A much better way is the following:

  1. Add the library’s jar file as an external jar to the libraries of the Android project (Properties > Java Build Path > Libraries > Add External JARs…)
  2. Expand the jar node in Properties > Java Build Path > Libraries.
  3. Double-click “Source attachment” > External location > Select the source file.
  4. Double-click “Javadoc location” > External location > Select the Javadoc file
  5. Properties > Java Build Path > Order and Export > Check the included library jar.  This is for preventing java.lang.NoClassDefFoundError