NoClassDefFoundError - Android 2.3.X

后端 未结 5 348
闹比i
闹比i 2021-01-07 09:40

I have a Task defined in a class. Fatal exception \"NoClassDefFoundError\" is happening on following line

MyCuteTask myTask = new MyCuteTask(equations)


        
相关标签:
5条回答
  • 2021-01-07 10:26

    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.

    0 讨论(0)
  • 2021-01-07 10:36

    This is an inner class please refer how to access the inner class object through outerclass else define your Myclass outside the Mainclass

    0 讨论(0)
  • 2021-01-07 10:37

    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

    0 讨论(0)
  • 2021-01-07 10:38

    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.

    0 讨论(0)
  • 2021-01-07 10:41

    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

    0 讨论(0)
提交回复
热议问题