出问题的log.
java.lang.NoSuchFieldError: No static field INSTANCE of type Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; in class Lorg/apache/http/conn/ssl/AllowAllHostnameVerifier; or its superclasses (declaration of 'org.apache.http.conn.ssl.AllowAllHostnameVerifier' appears in /system/framework/framework.jar!classes3.dex)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.<clinit>(SSLConnectionSocketFactory.java:151)
at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:977)
at com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder.build(WechatPayHttpClientBuilder.java:88)
at com.example.myapplication.MainActivity.sendHttpRequest2(MainActivity.java:250)
at com.example.myapplication.MainActivity.access$000(MainActivity.java:64)
at com.example.myapplication.MainActivity$2.run(MainActivity.java:186)
at java.lang.Thread.run(Thread.java:919)
使用wechatpay-apache-httpclient 0.4.8 SDK, 出错时的代码片段如下,创建WechatPayHttpClientBuilder的时候出现上述异常.
X509Certificate certificate = getCertificate(CERT_PATH + "wechatpay.pem");
List<X509Certificate> x509CertificateList = new ArrayList<>();
x509CertificateList.add(certificate);
PrivateKey privateKey = getPrivateKey(CERT_PATH + "apiclient_key.pem");
WechatPayHttpClientBuilder builder = WechatPayHttpClientBuilder.create()
.withMerchant(mch_id, mchSerialNo, privateKey)
.withWechatPay(x509CertificateList);
CloseableHttpClient httpClient = null;
try {
httpClient = builder.build();
} catch (IllegalArgumentException e) {
Log.e("ERROR", "IllegalArgumentException =" + e.getMessage());
}