Get Twitter timeline from service




I am trying to get a user timeline from an Android service, using guest authentication. Here is my code:

TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
Fabric.with(m_context, new Twitter(authConfig));

TwitterCore.getInstance().logInGuest(new Callback<AppSession>() {
    public void success(Result<AppSession> result) {

    public void failure(TwitterException arg0) {

When I do this from my MainActivity, it logs in successfully, but doing this from a thread in a service throws the following exception:

java.lang.ClassNotFoundException: Didn't find class "com.squareup.okhttp.OkUrlFactory" on path: DexPathList[[zip file "/data/app/com.example.twittertest-1/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

Is there something I need to do to get this to work from a service? (I am using an eclipse project that was modified using the Fabric plugin)



It looks like you’re missing dependency - you’ll need to add the jar to your class path