I’ve been going over Marko Gargenta’s Learning Android book, published by O’Reilly Media; in it he goes through the creation of a basic Twitter app. After struggling through the first example, I discovered two things:
- The examples in the book was using deprecated calls in the JTwitter library. Twitter had moved away from simple authentication and now prefers OAuth
- The android emulator was running super slow
I was able to resolve the first issue by doing a bit of independent research into how OAuth works in Android. I also switched over to the Twitter4J library as well. I’ll make a post about that later as it was a bit of a discovery process to get it all working.
To address the speed issue, a Stack Overflow search gave me this useful post: Slow Android Emulator
Using those two bits, I managed to get things up and running at a decent speed. Things were working great for a while until I started to get a mysterious
Invalid/Expired Token exception whenever I tried to authenticate the application through OAuth calls. After a bit of digging, I found out that the tokens that are issued via OAuth requests expire relatively shortly. The problem was, I was requesting these tokens immediately!
After stepping back for a bit, I realized that the Android emulator snapshot that I was using to speed up the boot-up process was conflicting with the OAuth token acquisition and verification. So the simple fix was to turn off Snapshots and use the Android AVD normally.