問題解決-使用Glide出現資源加載異常


項目報錯,處理步驟如下:

   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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM