項目報錯,處理步驟如下:
1>使用glide中的資源加載監聽器(Listener),抓取Log
listener(new RequestListener<String, GlideDrawable>() {
@Override
public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
Log.d(TAG,"onException:e="+e.toString()+";target:"+target+";isFirstResource="+isFirstResource);
Toast.makeText(getApplicationContext(),"資源加載異常",Toast.LENGTH_SHORT).show();
return false;
}
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
Log.e(TAG, "isFromMemoryCache:"+isFromMemoryCache+" model:"+model+" isFirstResource: "+isFirstResource);
Toast.makeText(getApplicationContext(),"圖片加載完成",Toast.LENGTH_SHORT).show();
return false;
}
})
2>Log如下:
javax.net.ssl.SSLHandshakeException: com.android.org.bouncycastle.jce.exception.ExtCertPathValidatorException:
Could not validate certificate:
Certificate not valid until Wed Nov 06 05:36:50 GMT+08:00 2013 (compared to Mon Nov 23 10:29:45 GMT+08:00 1970)
結論:從上面的Log可以看出這個圖片使用的是https協議(SSL協議,是一種安全傳輸協議),然后出現了這個問題。這個異常是說在校驗證書的時候出現時間校驗的失敗!
打開手機看一下時間是1970年時間,調整時間即可正常下載。
有幾位大牛提供了解決方案:
http://my.oschina.net/blackylin/blog/144136
http://www.eoeandroid.com/thread-161747-1-1.html
然后還有一篇關於https協議的好博文:
http://www.cnblogs.com/P_Chou/archive/2010/12/27/https-ssl-certification.html