0

I import a .jar according to these steps:

  1. under folder libs into you project root folder, I Copy my Jar files in this folder
  2. and right click on the Jar file and then select Build Path > Add to Build Path.

The jar appears under Android dependencies.

But i have this error : java.lang.NoClassDefFoundError: mypackage.MyClass

Please help me. I do not know how to solve it.

Alberto Alberto
  • 1,031
  • 2
  • 8
  • 6
  • Add it to classpath is should work , please update full stack trace in posts@Alberto Alberto – thar45 Nov 09 '12 at 11:06
  • right click on the project - properties - java build path - Order and export - tick Android private libraries and all the libraries that u added – Chris Sim Oct 18 '13 at 12:07

2 Answers2

1

If you are compiling your JAR in a different system, you are probably using a different JRE. try javac -version on both computers, and if they are differents, you can fix it focing the target JRE, like:

javac -target 1.6 -source 1.6 ...
Meir Gerenstadt
  • 3,573
  • 1
  • 23
  • 22
0

You also have to add it to the "Order and Export" tab on the Build path. Right click your project -> build path -> configure build path (assuming you're coding on eclipse.

Budius
  • 39,391
  • 16
  • 102
  • 144
  • I tried [this solution](http://androidandeclipse.blogspot.fr/2012/11/referenced-projects-and.html). It doesn't work. Here some images of my project : [package explorer](https://www.dropbox.com/s/cnmdlklknawqbq3/jar_project.PNG), [java build path](https://www.dropbox.com/s/87qhvquuu1w567e/order_export.PNG) – Alberto Alberto Nov 10 '12 at 17:55