Android crashing: java.lang.ClassCastException: com.capacitorjs.plugins.localnotifications.NotificationStorage.getSavedNotifications
Bug Report
@capacitor/local-notifications 5.0.6
Capacitor Version
Latest Dependencies:
@capacitor/cli: 5.6.0 @capacitor/core: 5.6.0 @capacitor/android: 5.6.0 @capacitor/ios: 5.6.0
Installed Dependencies:
@capacitor/core: 5.6.0 @capacitor/cli: 5.6.0 @capacitor/ios: 5.6.0 @capacitor/android: 5.6.0
Platform(s)
Android
Current Behavior
App crashes.
Example: samsung a52sxq (Galaxy A52s 5G) Android 14 (SDK 34)
Type java.lang.RuntimeException Exception java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at com.getcapacitor.Bridge.lambda$callPluginMethod$0 (Bridge.java:806) at com.getcapacitor.Bridge.$r8$lambda$ehFTi5f4HhVNFKTbCKAYDkpQYRA at com.getcapacitor.Bridge$$ExternalSyntheticLambda3.run at android.os.Handler.handleCallback (Handler.java:958) at android.os.Handler.dispatchMessage (Handler.java:99) at android.os.Looper.loopOnce (Looper.java:230) at android.os.Looper.loop (Looper.java:319) at android.os.HandlerThread.run (HandlerThread.java:67) Caused by java.lang.reflect.InvocationTargetException: at java.lang.reflect.Method.invoke at com.getcapacitor.PluginHandle.invoke (PluginHandle.java:138) at com.getcapacitor.Bridge.lambda$callPluginMethod$0 (Bridge.java:797) Caused by java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String at com.capacitorjs.plugins.localnotifications.NotificationStorage.getSavedNotifications (NotificationStorage.java:62) at com.capacitorjs.plugins.localnotifications.LocalNotificationsPlugin.getPending (LocalNotificationsPlugin.java:97)
Expected Behavior
App not crashing, catching the error instead.
Not been able to reproduce locally, but get multiple errors reported on Play console.
Other Technical Details
Looks to be related to this line in getSavedNotifications: String notificationString = (String) all.get(key);
Additional Context
Probably related to #434 #1156 seems the issue was not completely fixed.
This is still an issue with the latest capacitor v6 and accounts for the majority of my ANR reports.