1

I am getting the following error when trying to show an error message on the UI's 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;
}

What's the issue? I tried looking up but couldn't find anything related to the No field error_color_material message.

4

1 回答 1

4

原来我的应用程序模块的 build.Gradle 缺少支持库:

implementation 'com.android.support:design:28.0.0'

添加后一切都解决了,然后重新同步!

于 2018-09-12T09:52:56.897 回答