ClassNotFound/TypeNotPresentException using GSON on Android 2.2

Hooray for open software and fragmentation! Here’s one for the WTF list of very, very obscure programming bugs.

Apparently, if you’re using Google GSON, on an HTC built Android device, running Android OS 2.2, in a background thread, then you’re gonna have a bad time.

HTC decided to including GSON as a part of their private framework but when your Android app runs, it can ignore your files and decided to use HTC’s GSON—which doesn’t have access to reflect the classes in your app.

Hello random java.lang.TypeNotPresentException errors.

Instead of wasting hours like I did, just copy the GSON source directly into your project and rename the namespace.

Now please enjoy this meme while I go slam my head against a wall.