0

I'm using the TweetTimelineListAdapter from Fabric to display a list of tweets. This works fine with proguard disabled, but when I enable it, my UserTimeline object stops returning any success or failure in its callback.

There are no errors or exceptions in my log. Stepping through the code reveals that the guest login is successful and the tweets request is sent but no response is ever received.

Here's how I'm fetching the tweets:

private void loadTweets() {
    TwitterCore.getInstance().logInGuest(new Callback<AppSession>() {
        @Override
        public void success(Result<AppSession> result) {
            // logging in is successful, this code executes
            UserTimeline userTimeline = new UserTimeline.Builder()
                    .screenName("@ScreenName")
                    .maxItemsPerRequest(100)
                    .includeReplies(false)
                    .includeRetweets(true)
                    .build();

            mAdapter = new TweetTimelineListAdapter(TwitterActivity.this, userTimeline);
            mAdapter.registerDataSetObserver(mDataSetObserver);
            ((ListView) findViewById(R.id.tweet_list)).setAdapter(mAdapter);
        }

        @Override
        public void failure(TwitterException e) {
            Log.e(TwitterActivity.class.getName(), "Error performing guest login to twitter", e);
        }
    });
}

private DataSetObserver mDataSetObserver = new DataSetObserver() {
    @Override
    public void onChanged() {
        super.onChanged();

        // display data or error here based on results
        // this code is never executed
    }
};

Here's my proguard configuration file as recommended in the Fabric docs as well as some additions from me:

-dontwarn  com.digits.sdk.android.*ActionBarActivity

# retrofit specific
-dontwarn com.squareup.okhttp.**
-dontwarn com.google.appengine.api.urlfetch.**
-dontwarn rx.**
-dontwarn retrofit.**
-keepattributes Signature
-keepattributes *Annotation*
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
-keep class retrofit.** { *; }
-keepclasseswithmembers class * {
    @retrofit.http.* <methods>;
}

# GSON
-keep class com.google.gson.** { *; }
-keep interface com.google.gson.** { *; }
-dontwarn com.google.gson.**
howettl
  • 12,419
  • 13
  • 56
  • 91

1 Answers1

0

Along with your Proguard Setup that you have, you will also need to add

-keepclassmembers class com.company.user.* {
public *;
}

AND (very important)

-keepnames class * implements android.os.Parcelable {
       public static final ** CREATOR;
}

I had to learn the hard way that it is just safer to use as many proguard delimiters as possible so that you don't run into problems while shrinking custom libraries or sdks.

For more information on all the delimiters you need for proguard, just go here http://omgitsmgp.com/2013/09/09/a-conservative-guide-to-proguard-for-android/

AND maybe http://blog.androidquery.com/2011/06/android-optimization-with-proper.html

Tobi Akerele
  • 962
  • 10
  • 20
  • Should `com.company.user` in the first addition be my applications package? – howettl Jul 29 '15 at 19:26
  • Unfortunately these changes have no effect on my problem. I've added as many delimiters as I can think of but it seems I haven't stumbled on the correct one yet. – howettl Jul 29 '15 at 19:35
  • no, that was just a placeholder for whatever packager you have a problem with. – Tobi Akerele Jul 29 '15 at 19:41