Saturday, June 8, 2013

java.lang.NoClassDefFoundError - Android Development

Given that you have exported an existing project and try to run your android project via an emulator or your mobile phone,  and it seems to work just fine meaning that there is no compile time error or something and UI seems ok.  However when you click a button on the screen, suddenly you get such an error : "java.lang.NoClassDefFoundError in Android Development"

Do not worry ! There is always a reason behind the problem :)  It is actually about one of your jar files which cannot be found on runtime while JVM can find it in compile time.  If you are sure that your x.jar file is properly imported in your project in terms of its path, then there is one more thng you need to check.

 Ok our jar file seems ok, no error mark or something makes us guilty around our jar file :)
Then you should go to "Order and Export" tab as well.  And make sure that your jar file "BioHarnessBT.jar" in this case is checked !  If it is checked , run it and enjoy the result :)  and let all stress go away :)

Wednesday, June 5, 2013

Missing required library

It is actually an easy problem to solve. When you import an existing project into your workspace, you may face with such a problem since one of your jar files could not be found by the builder. That's why, some of the lines of codes are marked with red warning and try to warn you " I CANNOT FIND THE LIBRARY THAT YOU CLAIMED TO BE ON THE GIVEN PATH! "

Simply, right click your main project folder and go to properties. Then on the left menu find -> Java Build Path. Click Libraries tab and check the path of the jar file that most probably has a different path than the folder you have unzipped your project.rar.     Click edit and give the right path. Your problem has been solved ;)