尝试在用户界面的TextInputLayout
上显示错误消息时出现以下错误:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.blablabla.appname, PID: 23691
java.lang.NoSuchFieldError: No field error_color_material of type I in class Landroid/support/v7/appcompat/R$color; or its superclasses (declaration of 'android.support.v7.appcompat.R$color' appears in /data/app/com.blablabla.appname-2/split_lib_slice_6_apk.apk)
at android.support.design.widget.TextInputLayout.setErrorEnabled(TextInputLayout.java:654)
at android.support.design.widget.TextInputLayout.setError(TextInputLayout.java:721)
at android.support.design.widget.TextInputLayout.setError(TextInputLayout.java:708)
at com.blablabla.appname.activity.SetupProfileActivity.validateUsername(SetupProfileActivity.java:465)
SetupProfileActivity.java:465:
private boolean validateUsername() {
final String username = inputUsername.getText().toString().trim();
if (inputUsername.getText().toString().trim().isEmpty()) {
inputLayoutUsername.setError(getText(R.string.username_warning)); // Line 465
requestFocus(inputUsername);
return false;
} else {
inputLayoutFullName.setErrorEnabled(false);
}
return true;
}
有什么问题?我尝试查找,但找不到与No field error_color_material
消息相关的任何内容。
答案 0 :(得分:3)
结果是我的应用模块的构建。Gradle缺少支持库:
implementation 'com.android.support:design:28.0.0'
添加完所有内容后重新同步,一切都解决了!