Looking at the call stack, following call indicates that AsyncTask class was loaded on non-UI thread.
at android.os.HandlerThread.run(HandlerThread.java:60)
One of the Threading Rules mentioned in AsyncTask reference documentation is:
The AsyncTask class must be loaded on the UI thread. This is done automatically as of JELLY_BEAN.
Here is a bug related to this issue.
One of the solution is, load the AsyncTask
class manually in Application onCreate
method. This ensures the class gets loaded on main thread, before any application components uses it.
public class MyApplication extends Application {
@Override
public void onCreate() {
try {
Class.forName("android.os.AsyncTask");
} catch (ClassNotFoundException e) {
}
super.onCreate();
}
}
Remember to specify MyApplication
in AndroidManifest
file.