How to add a file .jar to an Android project in Eclipse

Adding a file .jar from the menu of Eclipse, File -> Properties -> Java Build Path -> Libraries -> Add External JARs…, causes an error, the project compiles but at runtime you get the error “NoClassDefFoundError” as if the file .jar was missing in the project.

To add correctly the file .jar:

  1. right click on the root of the project, New -> Folder, the directory name must be “libs”
  2. right click on the just created directory, Import -> General -> File System, and import the file .jar
  3. right click on the root of the project, Properties -> Java Build Path -> Libraries -> Add JARs…, (and not Add External JARs…), and select the file. jar from the libs directory

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.