Android Sncabar文本未显示在带有proguard的签名APK上
为什么Snacbar文本不显示在签名的APK上?下面是调试APK的代码。我还启用了proguard。这种情况发生是因为proguard吗Android Sncabar文本未显示在带有proguard的签名APK上,android,android-snackbar,Android,Android Snackbar,为什么Snacbar文本不显示在签名的APK上?下面是调试APK的代码。我还启用了proguard。这种情况发生是因为proguard吗 if (intent.hasExtra(KEY_ERROR_MESSAGE)) { String msg = intent.getStringExtra(KEY_ERROR_MESSAGE); Snackbar snack = Snackbar.make(findViewById(android.R.id.content), msg,
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();
}
编辑:
intent.hasExtra(KEY\u ERROR\u MESSAGE)
returntrue
但是intent.getStringExtra(KEY\u ERROR\u MESSAGE)
returnnull
不是预期的String
我应该使用哪些proguard规则 根据本文:您可能必须将这些异常添加到您的proguard规则文件中:
-dontwarn android.support.design.**
-keep class android.support.design.** { *; }
-keep interface android.support.design.** { *; }
-keep public class android.support.design.R$* { *; }
您是否尝试注释第4行至第9行并测试您的应用程序?并为Snackbar.make()提供另一个视图,而不是android.R.id.content