Widget.AppCompat.TextView not found after Migrate to material design

Viewed 2514

I've just migrated to material design 1.2.1 but i have some issues when building the application.

I've replaced all <TextView objects with <androidx.appcompat.widget.AppCompatTextView> and still have build issues.

The error is: AAPT: error: resource style/Widget.AppCompat.TextView (aka com.app.package:style/Widget.AppCompat.TextView) not found.

Note this are some of mine dependencies versions: Also keep in mind that before replace the appcompat library with material i've migrated to androidX using Studio plugin, also only with material 1.0.0 i don't have build problems.

implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
2 Answers

I faced the same problem, which I could not solve until I removed this block of code from the application module build.gradle file:

configurations.all {
    resolutionStrategy {
        eachDependency { DependencyResolveDetails details ->
            if (details.requested.group == 'androidx.appcompat') {
                details.useVersion "1.0.2"
            }
        }
    }
}

This code was intended to replace the AppCompat library version in all included dependencies with 1.0.2 vesrion (this was workaround to solve some problems with WebView). Perhaps you also had a script that replaces the version for appcompat.

I was able to fix this issue via:

  • Update all androidx libraries to the latest version.
  • Remove all dependencies like com.android.support:appcompat*
  • Replace all TextView with AppCompatTextView ot MaterialTextView
  • Update to the latest buildTools and Gradle plugin
Related