I was getting a pretty strange ClassCastException
when calling execute on an AsyncTask
. The exception was supposedly occurring at line 1 of the source file but this is impossible as line 1 is the package statement. The exception was being raised when the background thread called the doInBackground
method which I then redirected to another method called doInBackground
. The result was java.lang.ClassCastException: [Ljava.lang.Object;
. That funny shaped class is, I'm pretty sure, the Object[]
class.
After some digging I realized that this exception was happening because I was calling execute
on a non-typesafe reference to an AsyncTask ie the reference had no generic parameters. I don’t think this should raise an exception but it looks like the Dalvik VM doesn’t like it. Alas. If you run into the same problem just make sure you’re calling execute
on a type-safe reference.
Image may be NSFW.
Clik here to view.

Clik here to view.
