I have a livewallpaper application that implements a DreamService following the guide here and I am infrequently seeing crash reports come in with the following ClassCastException being thrown when it is launched:
Exception java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:4169)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:4325)
at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:101)
at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2574)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loopOnce (Looper.java:226)
at android.os.Looper.loop (Looper.java:313)
at android.app.ActivityThread.main (ActivityThread.java:8762)
at java.lang.reflect.Method.invoke
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:604)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1067)
Caused by java.lang.ClassCastException: android.os.BinderProxy cannot be cast to android.service.dreams.DreamService$DreamActivityCallback
at android.service.dreams.DreamActivity.onCreate (DreamActivity.java:63)
at android.app.Activity.performCreate (Activity.java:8591)
at android.app.Activity.performCreate (Activity.java:8570)
at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1384)
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:4150)
It appears to be only specific Samsung phones causing this, is there anything I can do to fix this, or is this a bug in Samsung code? Thanks
History of the changes in DreamActivity.java of AOSP shows this is apparently a known issue and fixed for Android 14. In here it's explained when this happens,
The DreamActivity is tied to a DreamService. When the DreamActivity is destroyed, so is the DreamService. If the DreamActivity is consequently recreated by the WM, this leads to a ClassCastException in the DreamActivity.onCreate method.
So given it's already fixed and the situation that was making it is out of reach for regular Android developers I guess there isn't much thing an app developer can or should do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With