简体   繁体   English

在Android上使用RESTEasyClient时出现NoSuchMethodError

[英]NoSuchMethodError when using RESTEasyClient on Android

I am developing an Android app and using a library that in turn depends on RESTEasyClient . 我正在开发一个Android应用程序并使用一个库,而这个库依赖于RESTEasyClient When using the library at runtime, I get a NoSuchMethodError : 在运行时使用库时,我得到一个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. 据我了解,这是因为与Android的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. 在线搜索,我发现了各种解决方案,包括org.apache.httpconnections:httpclient gradle依赖关系中的org.apache.httpconnections:httpclient ,并在几个变体中添加了compile.exclude module: httpclient (以解决产生的冲突)。 I have tried all these and invariably run into either an error from gradle or the NoSuchMethodError mentioned above. 我已经尝试了所有这些并且总是遇到gradle的错误或上面提到的NoSuchMethodError

Is it possible to successfully use RESTEasyClient on Android? 是否可以在Android上成功使用RESTEasyClient What steps do I need to take to enable this? 我需要采取哪些步骤才能启用此功能?

It all comes down to versions. 这一切都归结为版本。 The android version is a bit behind, and has not the same method signatures in the api. Android版本有点落后,并且在api中没有相同的方法签名。 Apaches recommendation is to add a specific version 4.3+ in the build file. Apaches建议在构建文件中添加特定版本4.3+。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM