I've seen quite a few threads about ClassNotFoundException and Android, but I have yet to find what I think is the reason for what I experience.
I have an app - Data counter widget - on Android Market. It has 250k+ downloads, and every time I release a new version I get a handful (1-5) of error reports about a ClassNotFoundException to my developer console in Android Market.
29 reports are from unspecified ('OTHER') devices, while two are from the Nexus One. There are two user messages: 'Crashes on startup' and 'During update install'.
All the reports are about my receivers (extends BroadcastReceiver). One of the receivers is triggered relatively often as it is the one that starts the service that reads and stores the data usage of the Android device. I have this feeling that it can be that an alarm is set (using AlarmManager) for the receiver and then the user/device upgrades the app and the class is not found - either because it's in a physical different package, or that it happens the moment the device does the swap. Could this be the case? And if so, are there any ways around it? I can't otherwise see why almost all reports (say 90%) comes on the same or next couple of days after a new release.
The stacktrace for one of my receivers (the others give the same stacktrace other than the class name):
java.lang.RuntimeException: Unable to instantiate receiver com.roysolberg.android.datacounter.receivers.CounterReceiver: java.lang.ClassNotFoundException: com.roysolberg.android.datacounter.receivers.CounterReceiver in loader dalvik.system.PathClassLoader[/data/app/com.roysolberg.android.datacounter-1.apk]
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2789)
at android.app.ActivityThread.access$3200(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: com.roysolberg.android.datacounter.receivers.CounterReceiver in loader dalvik.system.PathClassLoader[/data/app/com.roysolberg.android.datacounter-1.apk]
at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
at android.app.ActivityThread.handleReceiver(ActivityThread.java:2780)
... 10 more