0

We're getting this error from customers in large numbers after adding Google Play game services achievements to our app. There are two types of traces, this latest one (2nd trace below) starts from android.app.Application.onLowMemory() on a 4.0.4 device.

I'm puzzled by the trace. Could google-play-services_lib be registering an instance of com.google.android.gms.common.images.e (whatever that is) as if it is a ComponentCallbacks, then when the app tries to call a method on that instance the class cast exception is triggered? Both types of stacks we've seen -- due to onConfigurationChanged() or onLowMemory() -- are methods of http://developer.android.com/reference/android/content/ComponentCallbacks.html

Has anyone seen this exception? I have gotten it a couple times since adding google-play-services_lib to our project (we use it for achievements). It happens when our app is not active, perhaps when being paused (e.g. Home button) although once it seemed to occur when USB was unplugged -- as configuration changed is in the path maybe the device was switching portrait/landscape while being handled? It is not easily reproducible so I'm not sure what's happening yet.

16:05:35.587 DEBUG: onStop: disconnecting clients. lq
(... 17 seconds elapse with no events related to the app)
16:05:52.292
java.lang.ClassCastException: com.google.android.gms.common.images.e cannot be cast to android.content.ComponentCallbacks
    at android.app.Application.onConfigurationChanged(Application.java:91)
    at android.app.ActivityThread.performConfigurationChanged(ActivityThread.java:3800)
    at android.app.ActivityThread.handleConfigurationChanged(ActivityThread.java:3973)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1348)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:5041)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
    at dalvik.system.NativeStart.main(Native Method)


18:00:46.230 WTF: errorNoNotify: Exception "main": java.lang.ClassCastException: com.google.android.gms.common.images.e cannot be cast to android.content.ComponentCallbacks android.app.Application.onLowMemory(Application.java:99)  hm
java.lang.ClassCastException: com.google.android.gms.common.images.e cannot be cast to android.content.ComponentCallbacks
    at android.app.Application.onLowMemory(Application.java:99)
    at android.app.ActivityThread.handleLowMemory(ActivityThread.java:3690)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1233)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4424)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    at dalvik.system.NativeStart.main(Native Method)
mwk
  • 1,959
  • 1
  • 14
  • 22

1 Answers1

0

Looks like this is a bug in Google Play game services ImageManager.

We were using ImageManager loadImage() to load images for unlocked achievements. Because the class causing the exception is in the ImageManager package (android.gms.common.images) we tried updating the app to stop using ImageManager (switched to using APK image files). The bug has stopped, so I guess that's the cause

mwk
  • 1,959
  • 1
  • 14
  • 22
  • Are you still allowing device rotations ? The reason I ask is that I was seeing cast class exceptions (in my own fragments) when I was incorrectly handling orientation changes). Your problem is different (but not dissimilar). – IanB Jul 16 '13 at 16:08
  • @Sheldon Our Activity sets android:screenOrientation="sensorLandscape" android:configChanges="orientation". I don't know if our Activity settings would affect gplay service's fragment or not. The crash definitely stopped when we stopped using ImageManager, you would think if gplay just did not handle the orientation change correctly that would not have been related. Then again it's a weird thing :) – mwk Jul 17 '13 at 16:40