我在我的Android应用程序中遇到问题,在我的一个片段中,我使用volley来执行网络请求:
JsonObjectRequest request = new JsonObjectRequest(
Request.Method.POST,
CustomNetworkManager.getInstance(this.getActivity().getApplicationContext()).getRequestUrl(url),
requestData,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
// process response
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.d("FeedFragment", "Volley error: " + error.toString());
}
});
Run Code Online (Sandbox Code Playgroud)
在真实设备上,我收到以下错误(运行API23):
D/FeedFragment: Volley error: com.android.volley.NoConnectionError: javax.net.ssl.SSLHandshakeException: java.security.cert.CertPathValidatorException: Trust anchor for certification path not found.
Run Code Online (Sandbox Code Playgroud)
在运行相同API版本的AVD中,它工作正常.我检查了其他类似的线程,但找不到答案.
谢谢你的帮助.
编辑:如果有人遇到相同的错误,请确保您的证书没有任何问题(http://developer.android.com/intl/pt-br/training/articles/security-ssl.html#CommonProblems)