0

Following is the snap shot of the eclipse's package explorer. I use the opencsv library for the app project. I added the jar to referenced libraries in main project. I define a class 'X' in main project that extends a class from the jar library project.

When I create an instance of class 'X' it gives

java.lang.NoClassDefFoundError

I tried to add the library in Properties>Android>Add... but since the opencsv is a java project and not android library project, it doesnt show up in the list to select.

Somehting missing?

enter image description here

user2432627
  • 157
  • 1
  • 2
  • 14
  • Please mention the full stackTrace. – Jhanvi Dec 19 '13 at 11:52
  • @Jhanvi Nothing special in the stacktrace. I try 'DIPReader rdr = new DIPReader(filename)' and it crashes. `DIPReader` extends `CSVReader` class from the opencsv library.. – user2432627 Dec 19 '13 at 11:56
  • Try reading this two posts: http://stackoverflow.com/questions/1334802/how-can-i-use-external-jars-in-an-android-project http://stackoverflow.com/questions/8678630/noclassdeffounderror-for-code-in-an-java-library-on-android – nico Dec 19 '13 at 11:57
  • Must Check that jar file also in **libs** folder. – Piyush Dec 19 '13 at 12:10
  • @nico the second did help in correcting the Order of the library in Order & Export window. but still I get the error.. – user2432627 Dec 19 '13 at 13:13
  • @Piyush Gupta There is another library in `Android Dependences` folder. I didnt have to add it to the libs folder. And it works fine. That is not the issue. – user2432627 Dec 19 '13 at 13:16
  • You'll only get superficial answers unless you tell people which class exactly is giving NoClassDefFoundError. Suggest you to follow this to understand and debug - http://javareferencegv.blogspot.com/2013/10/debugging-javalangnoclassdeffounderror.html – Crickcoder Dec 19 '13 at 20:08
  • have a look on my post. this should helo you – Festus Tamakloe Jan 08 '14 at 16:36

3 Answers3

0

Did you mark that library for export? Properties->Java Build Path->Order and Export?

alxio
  • 128
  • 4
0

check private libraries and dependancies as export entities for your library project. see this attachmentclick here

nikvs
  • 1,090
  • 5
  • 9
0

You have here 2 possibilities:

  1. Transform you opencv project into android library project and bind it as library in your main project

  2. Copy & paste the openCSV-2.3.jar in the libs folder from your main project. It will apprears automatically in references libraries

Festus Tamakloe
  • 11,231
  • 9
  • 53
  • 65