1

I am using my own custom java library to read response from the server by hitting urls. I have written a standalone java program to check whether the library is working or not and I am getting the positive responses for all the urls. But when I am trying to use the same java library with my android code it is throwing me an exception.

Exception:
Could not find class 'org.apache.http.impl.conn.PoolingClientConnectionManager', referenced from method com.nq.client.comm.HttpClientHelper.<init>.
java.lang.NoClassDefFoundError: org.apache.http.impl.conn.PoolingClientConnectionManager
Vikas Gill
  • 31
  • 3

1 Answers1

0

You probably want to export the library in your Java Build Path:

See Android - Unable to instantiate activity - Class not found exception after upgrading to ADT 22

EDIT In your custom library project, make sure you are exporting in the Java Build path the Apache library (org.apache.http.impl.conn.PoolingClientConnectionManager). The error message is telling you that there is a reference to this library, but it cannot be found. This means that it's not being packaged with the library that is referencing it. So, go to your custom library project and make sure that the Apache library is getting exported. If it is, raise it up in the list in order of export.

Community
  • 1
  • 1
Roy Hinkley
  • 10,111
  • 21
  • 80
  • 120
  • yes I have exported the library in the java build path. the line where I am getting the exception is :- PoolingClientConnectionManager pccm = new PoolingClientConnectionManager(SchemeRegistryFactory.createDefault()); – Vikas Gill May 02 '14 at 13:13
  • @VikasGill Are you exporting the Apache lib too? – Roy Hinkley May 02 '14 at 13:15
  • No they all are bundled in my custom library. – Vikas Gill May 02 '14 at 13:17
  • @VikasGill Then you need to export that lib path in your custom lib project. – Roy Hinkley May 02 '14 at 13:19
  • sorry I didn't get you can you explain me on this. – Vikas Gill May 02 '14 at 13:22
  • @VikasGill In your project you are exporting your custom lib in your build path. However, since the Apache lib is in your custom lib, you need to export the Apache lib build path in that project, before you compile it. Otherwise, the Apache lib is referenced, but not built with the custom lib. – Roy Hinkley May 02 '14 at 13:25
  • Still no luck!Can you give an example so that it will be very helpful 2 me. – Vikas Gill May 02 '14 at 13:35
  • Sorry brother its not happening. – Vikas Gill May 02 '14 at 14:14
  • @VikasGill I don't know how else to explain it. You are referencing a library that is not there at run-time. There is no other way to put it. – Roy Hinkley May 02 '14 at 14:16
  • I am using eclipse to generate jar file and on extracting them I am able to see some folders 2 of them are generated class files and lib folder containing the Apache lib. – Vikas Gill May 02 '14 at 14:25