Getting NoClassDefFoundError: android.os.AsyncTask

后端 未结 3 1001
轮回少年
轮回少年 2020-12-10 04:48

This problem has been bothering me for a bit and I cannot find a satisfactory solution.

Many times (not always) in the creation of a specific object on the Android e

相关标签:
3条回答
  • 2020-12-10 05:28

    I think I have cracked it.

    The thread used to load ads in my app would throw an uncaught exception early on which, in a way I don't 100% understand, caused the worker thread to stop responding. When the program tried to create the AsyncTask the class loader was not working.

    Moral, take a vacation and come back with fresh eyes.

    0 讨论(0)
  • 2020-12-10 05:32

    Try adding a simple constructor in StatisticsProvider and check.

    0 讨论(0)
  • 2020-12-10 05:46

    OK, 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

    Looks like a work around might be to add:

    try {
          Class.forName("android.os.AsyncTask");
    }
    catch(Throwable ignore) {
          // ignored
    }
    

    into your Application#onCreate()

    If you don't already have a Application class then create a class that extends from android.app.Application and

    1. Add the code above into its #onCreate()
    2. Add a reference to your application class in the application element of your AndroidManifest.
    <application android:icon="@drawable/icon_game_launcher"
                 android:label="@string/app_name"
                 android:name="au.com.mycompany.myapp.MyApplication">
    
    0 讨论(0)
提交回复
热议问题