0

Why Snacbar Text not showing on Signed APK? here is the code which working on debug APK. I enabled the proguard also. Does this happen because of the proguard ?

  if (intent.hasExtra(KEY_ERROR_MESSAGE)) {
     String msg = intent.getStringExtra(KEY_ERROR_MESSAGE);
     Snackbar snack = Snackbar.make(findViewById(android.R.id.content), msg, Snackbar.LENGTH_LONG);

     View view = snack.getView();
     view.setBackgroundColor(ContextCompat.getColor(SignupActivity.this, R.color.red_EC1C24));

     TextView tv = (TextView) view.findViewById(android.support.design.R.id.snackbar_text);
     tv.setTextColor(ContextCompat.getColor(SignupActivity.this, R.color.accent));
     tv.setGravity(Gravity.CENTER_HORIZONTAL);
     snack.show();
  }

EDIT:

intent.hasExtra(KEY_ERROR_MESSAGE) return true but intent.getStringExtra(KEY_ERROR_MESSAGE) return null not the expected String

What are the proguard rules should I use ?

Chathura Wijesinghe
  • 3,310
  • 3
  • 25
  • 41

1 Answers1

0

According to this article: https://androidbycode.wordpress.com/2015/06/06/material-design-snackbar-using-the-design-support-library/ you may have to add these exceptions into your proguard rules file:

-dontwarn android.support.design.**
-keep class android.support.design.** { *; }
-keep interface android.support.design.** { *; }
-keep public class android.support.design.R$* { *; }
viplezer
  • 5,519
  • 1
  • 18
  • 25