簡體   English   中英

在Android上使用RESTEasyClient時出現NoSuchMethodError

[英]NoSuchMethodError when using RESTEasyClient on Android

我正在開發一個Android應用程序並使用一個庫,而這個庫依賴於RESTEasyClient 在運行時使用庫時,我得到一個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)

據我了解,這是因為與Android的Apache HttpClient實現不兼容。 在線搜索,我發現了各種解決方案,包括org.apache.httpconnections:httpclient gradle依賴關系中的org.apache.httpconnections:httpclient ,並在幾個變體中添加了compile.exclude module: httpclient (以解決產生的沖突)。 我已經嘗試了所有這些並且總是遇到gradle的錯誤或上面提到的NoSuchMethodError

是否可以在Android上成功使用RESTEasyClient 我需要采取哪些步驟才能啟用此功能?

這一切都歸結為版本。 Android版本有點落后,並且在api中沒有相同的方法簽名。 Apaches建議在構建文件中添加特定版本4.3+。

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