It's happening due to the precondition of typeText i.e.
View preconditions:
must be displayed on screen
must support input methods
Input method is not supported by TextView
(user cannot input values into it via keyboard or something else) so hence the issue
Solution : you can implement your own view ViewAction
From how to create View action to set text on TextView
public static ViewAction setTextInTextView(final String value){
return new ViewAction() {
@SuppressWarnings("unchecked")
@Override
public Matcher<View> getConstraints() {
return allOf(isDisplayed(), isAssignableFrom(TextView.class));
// ^^^^^^^^^^^^^^^^^^^
// To check that the found view is TextView or it's subclass like EditText
// so it will work for TextView and it's descendants
}
@Override
public void perform(UiController uiController, View view) {
((TextView) view).setText(value);
}
@Override
public String getDescription() {
return "replace text";
}
};
}
then you can do
onView(withId(R.id.editText))
.perform(setTextInTextView("my text"));