I am seeing this error in a live app thus I have no clue why this happening. All I have is this exception log (see below). At first, I thought I applied style editTextBackgr
The main cause of this problem seems to be a missing style/theme in the AppCompat library, or a bug in the library. It happens when using either AppCompatEditText or AppCompatAutoCompleteTextView and a WebView is also added to the layout (AdMob ads are WebViews). It happens on several versions of AppCompat, like 23, 24, 25, 26.
It can be seen more clearly in a useful demo app that someone made on Github:
build.gradle:
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
...
}
app/build.gradle:
buildToolsVersion '25.0.0'
gradle-wrapper.properties:
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
The solution (from here) is to explicitly add both "colorAccent"
and "android:colorAccent"
in your main AppTheme, in styles.xml:
<style name="AppTheme" parent="Theme.AppCompat">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:colorAccent" tools:targetApi="lollipop">@color/colorAccent</item>
</style>
or
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:colorAccent" tools:targetApi="lollipop">@color/colorAccent</item>
</style>
This will now work to allow the stock spelling suggestions popup to appear, and no more crashing.
Similar reports or duplicates:
Had exact same exception while using AutoCompleteTextView. Replication was really tough and wasted my two days in this.
The cause for this is Google spell checker popup, enabled in some devices which causes red line under words in Edittext/AutoCompleteEdittext and clicking on it opens a popup of spell suggestions. According to my observations this popup doesn't go too well in TextInputLayout(with style) and causes crash in some devices (in my case it was Moto G play). You can verify it by turning off the Google spell checker and it will work fine. But the real solution is to add
android:inputType="textNoSuggestions"
to your edittext in XML
This disables the spell checker for that edittext and rest works fine.
Let me know if it helped.
according to the answer of @Abhinav Pawar, I used
android:inputType="textAutoCorrect"
instead of
android:inputType="textNoSuggestions"
In fact, textNoSuggestions remove all suggested words by the keyboard at typing. While textAutoCorrect replace the wrong word by the good one. And the user is free to use the one he wants.