16

I am developing an Android app and using a library that in turn depends on RESTEasyClient. When using the library at runtime, I get a NoSuchMethodError:

java.lang.NoSuchMethodError: No direct method <init>(Ljavax/net/ssl/SSLContext;Lorg/apache/http/conn/ssl/X509HostnameVerifier;)V in class Lorg/apache/http/conn/ssl/SSLSocketFactory; or its super classes (declaration of 'org.apache.http.conn.ssl.SSLSocketFactory' appears in /system/framework/ext.jar)
                      at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.initDefaultEngine(ResteasyClientBuilder.java:418)
                      at org.jboss.resteasy.client.jaxrs.ResteasyClientBuilder.build(ResteasyClientBuilder.java:333)

As I understand it, this is because of an incompatibility with Android's implementation of Apache HttpClient. Searching online, I have found various solutions revolving around including org.apache.httpconnections:httpclient in the gradle dependencies and adding compile.exclude module: httpclient (to resolve the resulting conflict) in several variations. I have tried all these and invariably run into either an error from gradle or the NoSuchMethodErrormentioned above.

Is it possible to successfully use RESTEasyClient on Android? What steps do I need to take to enable this?

3
  • 3
    share your code.
    – Devratna
    Jun 3, 2018 at 2:29
  • 1
    Isn't RESTEasy meant to be used in JBoss EAP only, as all implementations are provided by the Server Runtime.
    – soufrk
    Jun 4, 2018 at 10:10
  • 1
    Share you gradle/maven Jun 5, 2018 at 6:52

1 Answer 1

1
+50

It all comes down to versions. The android version is a bit behind, and has not the same method signatures in the api. Apaches recommendation is to add a specific version 4.3+ in the build file.

http://hc.apache.org/httpcomponents-client-4.3.x/android-port.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.