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

Here are my build.gradle dependencies (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 the build.gradle part (Project)

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

When I go to any xml file, it shows me an error ** The following classes cannot be created:

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

I updated Android Studio to the latest version showing an error.

I can not understand the problem. Thanks.

+7
android android-gradle android-xml build.gradle appcompat
source share
5 answers

EDIT

When you add the maven repository, this problem will occur.
See The same mistake I came across on a question asked by my friend here , as I cannot ask.

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

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

to

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

He decided mine and did not forget the actual answer.

+8
source share

In styles.xml ,

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

Credit: fooobar.com/questions/847226 / ...

+2
source share

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

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

I replaced it and it works great

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

If you encounter one of these errors, inserted below, you may need to view your settings in styles.xml files. I ran into this problem after I changed my build tools in the build.gradle file from buildToolsVersion '23 .0.0 ' to buildToolsVersion '26 .0.2'

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

The following classes cannot be created:

- 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)

0
source share

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

0
source share

All Articles