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

Appcelerator JIRA | Jason Priebe | 2 years ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  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

    Help:basic RMI question

    Google Groups | 2 decades ago | Paolo De Lutiis
    java.lang.ClassCastException: serverPackage.ServerClass_Stub at clientPackage.myApplet.init(myApplet.java:line#) at sun.applet.AppletPanel.run(AppletPanel.java:273) at java.lang.Thread.
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Shared hosting Bungeecord problems.

    GitHub | 3 years ago | Arksenu
    java.lang.ClassCastException: bka cannot be cast to fs All my servers are set to onlinemode: false Here is my config.yml groups: arksenu: - admin disabled_commands: - find player_limit: -1 stats: 347d1d62-6fb6-4869-bd43-7d0745de8e3c permissions: default: - bungeecord.command.server - bungeecord.command.list admin: - bungeecord.command.ip - bungeecord.command.alert - bungeecord.command.end - bungeecord.command.reload listeners: - max_players: 18 fallback_server: hub host: 0.0.0.0:35289 bind_local_address: true ping_passthrough: false tab_list: GLOBAL_PING default_server: hub forced_hosts: pvp.md-5.net: hub tab_size: 60 force_default_server: true motd: ’Network’ query_enabled: false query_port: 25565 timeout: 30000 connection_throttle: 4000 servers: hub: address: 108.170.8.146:35289 restricted: false motd: test UvGames: address: 66.85.165.170:26200 restricted: false motd: test UvPrison: address: 66.85.128.90:25928 restricted: false motd: test ip_forward: false online_mode: true And here is my console message -> UpstreamBridge has disconnected disconnected with: Exception Connecting:RuntimeException : Server is online mode! @ net.md_5.bungee.ServerConnector:188
  6. 0

    Shared hosting Bungeecord problems.

    GitHub | 3 years ago | Arksenu
    java.lang.ClassCastException: bka cannot be cast to fs All my servers are set to onlinemode: false Here is my config.yml groups: arksenu: - admin disabled_commands: - find player_limit: -1 stats: 347d1d62-6fb6-4869-bd43-7d0745de8e3c permissions: default: - bungeecord.command.server - bungeecord.command.list admin: - bungeecord.command.ip - bungeecord.command.alert - bungeecord.command.end - bungeecord.command.reload listeners: - max_players: 18 fallback_server: hub host: 0.0.0.0:35289 bind_local_address: true ping_passthrough: false tab_list: GLOBAL_PING default_server: hub forced_hosts: pvp.md-5.net: hub tab_size: 60 force_default_server: true motd: ’Network’ query_enabled: false query_port: 25565 timeout: 30000 connection_throttle: 4000 servers: hub: address: 108.170.8.146:35289 restricted: false motd: test UvGames: address: 66.85.165.170:26200 restricted: false motd: test UvPrison: address: 66.85.128.90:25928 restricted: false motd: test ip_forward: false online_mode: true And here is my console message -> UpstreamBridge has disconnected disconnected with: Exception Connecting:RuntimeException : Server is online mode! @ net.md_5.bungee.ServerConnector:188

    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