samugi
samugi

Reputation: 395

Apache HttpAsyncClient throwing NoSuchMethodError

When executing: Future<HttpResponse> future = myHttpAsyncClient.execute(post, null); i get this:

12-02 02:22:03.567: W/dalvikvm(6392): threadid=13: thread exiting with uncaught exception (group=0x40b5c930)

...

Caused by: java.lang.NoSuchMethodError: org.apache.http.client.utils.URIUtils.extractHost
12-02 02:22:03.606: E/AndroidRuntime(6392):     at org.apache.http.impl.nio.client.AbstractHttpAsyncClient.determineTarget(AbstractHttpAsyncClient.java:594)

...

I found this question: Apache HttpAsyncClient - NoSuchMethodError - URIUtils.extractHost but i've not properly understood what i've to do to fix the problem. Thank you

Upvotes: 2

Views: 1505

Answers (1)

Akdeniz
Akdeniz

Reputation: 1270

Unfortunately there is an incompatibility issue with android internal httpcore and external httpasyncclient library. Android relies on older version of httpcore. Even if you export your application with newer version of it, android still uses the internal one because of the same package.

So possible solutions are:

  • using maven shade plugin to relocate all classes of httpasyncclient and its dependencies to another package structure and export it with your application.
  • using equivalent library such as android-async-http

Upvotes: 3

Related Questions