Since a couple of weeks, I'm seeing more and more crashes of my app with the following exception
Fatal Exception: java.lang.NoClassDefFoundError android.os.AsyncTask
This code has run for month without any issue, and it seems now to fail on some devices (75% android 2.3.x and 25% android 4.0.3) It fails when I create a new instance of a class which extends AsyncTask.
I create this class from the UI thread.
How can that class be not found as it's defined within the SDK ?
Yes, looks like it is a problem with one of the versions of Google play Services. See https://code.google.com/p/android/issues/detail?id=81083
A work around is to add:
try {
Class.forName("android.os.AsyncTask");
}
catch(Throwable ignore) {
// ignored
}
into your Application#onCreate()
this appears to ensure that the root classloader loads AsyncTask so that it is then available from within Play Services.
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