I have a Task defined in a class. Fatal exception \"NoClassDefFoundError\" is happening on following line
MyCuteTask myTask = new MyCuteTask(equations)
I had the same problem and I have copied source code of the AsyncTask as MyAsyncTask into my project and extended from that class, now it works.
This is an inner class please refer how to access the inner class object through outerclass else define your Myclass outside the Mainclass
Asynctask was added in API level 3. Please verify one by checking the same code with API 3. If it disappears, there is your problem
Its an google play services issue. (https://code.google.com/p/android/issues/detail?id=81083)
Workaround to avoid this crash till Google fixes it:
Add following into your Application#onCreate() method
try {
Class.forName("android.os.AsyncTask");
}
catch(Throwable ignore) {
// ignored
}
Note its Application#onCreate() and not Activity#onCreate()
Update: I can verify that above changes fixed these crashes for me.
I reported the same error here: Android: NoClassDefFoundError android.os.AsyncTask Because it started happening without any app delivery it looks like yet another Google Play Services bug... I'm having 83% of crashes on Android 2.3.x and 16% on crashes on 4.0.3 & 4.0.4