Home » Android » The following classes could not be instantiated android.support.v7.widget.AppCompatTextView

The following classes could not be instantiated android.support.v7.widget.AppCompatTextView

Posted by: admin May 14, 2020 Leave a comment

Questions:

Here are my dependencies of build.gradle(app)

compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', 
{
    exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.firebaseui:firebase-ui-auth:2.3.0'
compile 'com.android.support:appcompat-v7:26.0.1'
compile 'com.android.support:design:26.0.1'
compile 'com.android.support:support-vector-drawable:26.0.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'

Here is a part of build.gradle(Project)

allprojects {
    repositories {
        jcenter()
        maven { url "https://maven.google.com" }
    }
}

When I am going to any xml file it is showing me an error **The following classes could not be instantiated:

 android.support.v7.widget.AppCompatTextView (Open Class, Show Exception, Clear Cache)**

I have updated Android Studio to the latest still it shows the error.

I am unable to figure out the problem.Thank you

How to&Answers:

EDIT

Whenever You’ll add maven repository, this problem will occur.
See same error I’m facing on a question asked by my friend here as I can’t ask.


This can be solved by changing AppTheme in res -> values -> Styles.xml
change your theme from

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

to

<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">

It solved mine and don’t forget the actual answer.

Answer:

In styles.xml,

Changing the theme from Theme.AppCompat.Light.DarkActionBar to Base.Theme.AppCompat.Light.DarkActionBar has worked for me.

Credit goes to: https://stackoverflow.com/a/45399080/8111914

Answer:

I had the same error while using Theme.AppCompat.NoActionBar

<style name="AppTheme" parent="Theme.AppCompat.NoActionBar">

I replaced it by and it works fine:

<style name="AppTheme" parent="Base.Theme.AppCompat">
    <item name="windowActionBar">false</item>
    <item name="windowNoTitle">true</item>
</style>

Answer:

If you have encountered one of these errors pasted below, you might need to review your settings in styles.xml files. I encountered this problem after I changed my build Tools in build.gradle file from buildToolsVersion ‘23.0.0’ to buildToolsVersion ‘26.0.2’

To specifically solve the problem, if you have a line similar to this
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> change it to include the Base prefix, for instance in my case I changed from <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> to <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar"> and everything worked fine.

The following classes could not be instantiated:

– android.support.v7.widget.AppCompatImageView (Open Class, Show Exception, Clear Cache)

– android.support.v7.widget.AppCompatButton (Open Class, Show Exception, Clear Cache)

– android.support.v7.widget.Toolbar (Open Class, Show Exception, Clear Cache)

– android.support.v7.widget.AppCompatEditText (Open Class, Show Exception, Clear Cache)

– android.support.v7.widget.AppCompatTextView (Open Class, Show Exception, Clear Cache)

– android.support.v7.widget.ActionBarContextView (Open Class, Show Exception, Clear Cache)

– android.support.v7.app.WindowDecorActionBar (Open Class, Show Exception, Clear Cache)

– android.support.v7.widget.ActionBarOverlayLayout (Open Class, Show Exception, Clear Cache)

Answer:

I had a hard corded color value and after removing it everything worked just fine

Answer:

Please change the theme style in
res -> values -> Styles.xml

From : <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

To : <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">

Answer:

This can be solved by changing AppTheme in res -> values -> Styles.xml change your theme from

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">

to

<style name="AppTheme" parent="Base.Theme.AppCompat">