java.lang.ClassCastException: com.android.okhttp.HttpResponseCache cannot be cast to org.appcelerator.titanium.util.TiResponseCache

Appcelerator JIRA | Jason Priebe | 2 years ago
  1. 0

    My app is crashing when I use Google Play Services to deliver doubleclick ads. {code:title=console output|borderStyle=solid} [ERROR] : TiDownloadManager: (pool-4-thread-1) [18,3778] Exception downloading http://wwwcache.wral.com/asset/news/local/2014/09/26/14018104/14018104-1411727089-320x180.jpg [ERROR] : TiDownloadManager: java.lang.ClassCastException: com.android.okhttp.HttpResponseCache cannot be cast to org.appcelerator.titanium.util.TiResponseCache [ERROR] : TiDownloadManager: at org.appcelerator.titanium.util.TiResponseCache.peek(TiResponseCache.java:187) [ERROR] : TiDownloadManager: at ti.modules.titanium.ui.widget.TiUIImageView$1.postDownload(TiUIImageView.java:119) [ERROR] : TiDownloadManager: at org.appcelerator.titanium.util.TiDownloadManager$DownloadJob.run(TiDownloadManager.java:151) [ERROR] : TiDownloadManager: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) [ERROR] : TiDownloadManager: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) [ERROR] : TiDownloadManager: at java.lang.Thread.run(Thread.java:841) [DEBUG] : dalvikvm: DexOpt: --- END 'ads646200884.jar' (success) --- {code} (the URL listed in the output is an image that I am loading into an ImageView, so I inferred that the TiDownloadManager is handling the loading of ImageView images) The problem only goes away if I disable DFP ads (I'm using my own ti.dfp module - https://github.com/jpriebe/ti.dfp). I found it strange that it was crashing, because this code was working just a few days ago, and the module had not been changed, nor had I really done anything to the app and the way it handles ImageViews. I scoured android source code, tweets, and forum posts, and I've learned that in android 4.4, Square's okhttp code is supposedly incorporated into HttpUrlConnection. However, I've never found any code for com.android.okhttp.HttpResponseCache. The only code I can find is for com.squareup.okhttp.HttpResponseCache, not "com.android". com.squareup.okhttp.HttpResponseCache extends java.net.ResponseCache, just like TiResponseCache does. But the code in TiResponseCache.peek() is only expecting to get back a TiResponseCache object when it calls getDefault(). Changing that might not be trivial, since it depends on the cacheDir member variable of the returned object, and that's not part of the java.net.ResponseCache class. Here's what I think has happened -- google released Google Play Services 6.1.09 on September 23, 2014. It automatically updated on my device. Inside the new Google Play Services is a call to ResponseCache.setDefault(), and they're setting that default to a com.android.okhttp.HttpResponseCache object. Titanium assumes that the default system ResponseCache is the one that it set in TiApplication.java, and it doesn't handle things well when somebody else messes with the default. I don't know what the fix is for this -- I'll leave that to the android platform experts in your employ. But I think it is a critical issue, and will become more obvious in the coming days as this Play Services update propagates. Any app that is using Google Play Services (or at least the DFP portion of it) and the TiDownloadManager will crash.

    Appcelerator JIRA | 2 years ago | Jason Priebe
    java.lang.ClassCastException: com.android.okhttp.HttpResponseCache cannot be cast to org.appcelerator.titanium.util.TiResponseCache
  2. 0

    My app is crashing when I use Google Play Services to deliver doubleclick ads. {code:title=console output|borderStyle=solid} [ERROR] : TiDownloadManager: (pool-4-thread-1) [18,3778] Exception downloading http://wwwcache.wral.com/asset/news/local/2014/09/26/14018104/14018104-1411727089-320x180.jpg [ERROR] : TiDownloadManager: java.lang.ClassCastException: com.android.okhttp.HttpResponseCache cannot be cast to org.appcelerator.titanium.util.TiResponseCache [ERROR] : TiDownloadManager: at org.appcelerator.titanium.util.TiResponseCache.peek(TiResponseCache.java:187) [ERROR] : TiDownloadManager: at ti.modules.titanium.ui.widget.TiUIImageView$1.postDownload(TiUIImageView.java:119) [ERROR] : TiDownloadManager: at org.appcelerator.titanium.util.TiDownloadManager$DownloadJob.run(TiDownloadManager.java:151) [ERROR] : TiDownloadManager: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) [ERROR] : TiDownloadManager: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587) [ERROR] : TiDownloadManager: at java.lang.Thread.run(Thread.java:841) [DEBUG] : dalvikvm: DexOpt: --- END 'ads646200884.jar' (success) --- {code} (the URL listed in the output is an image that I am loading into an ImageView, so I inferred that the TiDownloadManager is handling the loading of ImageView images) The problem only goes away if I disable DFP ads (I'm using my own ti.dfp module - https://github.com/jpriebe/ti.dfp). I found it strange that it was crashing, because this code was working just a few days ago, and the module had not been changed, nor had I really done anything to the app and the way it handles ImageViews. I scoured android source code, tweets, and forum posts, and I've learned that in android 4.4, Square's okhttp code is supposedly incorporated into HttpUrlConnection. However, I've never found any code for com.android.okhttp.HttpResponseCache. The only code I can find is for com.squareup.okhttp.HttpResponseCache, not "com.android". com.squareup.okhttp.HttpResponseCache extends java.net.ResponseCache, just like TiResponseCache does. But the code in TiResponseCache.peek() is only expecting to get back a TiResponseCache object when it calls getDefault(). Changing that might not be trivial, since it depends on the cacheDir member variable of the returned object, and that's not part of the java.net.ResponseCache class. Here's what I think has happened -- google released Google Play Services 6.1.09 on September 23, 2014. It automatically updated on my device. Inside the new Google Play Services is a call to ResponseCache.setDefault(), and they're setting that default to a com.android.okhttp.HttpResponseCache object. Titanium assumes that the default system ResponseCache is the one that it set in TiApplication.java, and it doesn't handle things well when somebody else messes with the default. I don't know what the fix is for this -- I'll leave that to the android platform experts in your employ. But I think it is a critical issue, and will become more obvious in the coming days as this Play Services update propagates. Any app that is using Google Play Services (or at least the DFP portion of it) and the TiDownloadManager will crash.

    Appcelerator JIRA | 2 years ago | Jason Priebe
    java.lang.ClassCastException: com.android.okhttp.HttpResponseCache cannot be cast to org.appcelerator.titanium.util.TiResponseCache
  3. 0

    Memcached Java客户端2.6.1发布 - 编程语言 - ITeye资讯

    iteye.com | 1 year ago
    java.lang.ClassCastException: cannot be cast to
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Scala 2.11.5 and Squeryl?

    Google Groups | 2 years ago | Clint Gilbert
    java.lang.ClassCastException: scala.None$ cannot be cast to
  6. 0

    adam2vcf

    Google Groups | 8 months ago | someya sayeh
    java.lang.ClassCastException: org.bdgenomics.formats.avro.Fragment cannot be cast to

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.ClassCastException

      com.android.okhttp.HttpResponseCache cannot be cast to org.appcelerator.titanium.util.TiResponseCache

      at org.appcelerator.titanium.util.TiResponseCache.peek()
    2. org.appcelerator.titanium
      TiResponseCache.peek
      1. org.appcelerator.titanium.util.TiResponseCache.peek(TiResponseCache.java:187)
      1 frame
    3. ti.modules.titanium
      TiUIImageView$1.postDownload
      1. ti.modules.titanium.ui.widget.TiUIImageView$1.postDownload(TiUIImageView.java:119)
      1 frame
    4. org.appcelerator.titanium
      TiDownloadManager$DownloadJob.run
      1. org.appcelerator.titanium.util.TiDownloadManager$DownloadJob.run(TiDownloadManager.java:151)
      1 frame
    5. Java RT
      Thread.run
      1. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
      2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
      3. java.lang.Thread.run(Thread.java:841)
      3 frames