11

I am having problems figuring out what to do to solve this error.
I tried invalidating caches/restart, freed up disk space and reinstalling Android Studio.

The following classes could not be instantiated:
    - android.support.v7.widget.AppCompatTextView(Open Class, Show Exception, Clear Cache)
Tip: Use View.isInEditMode() in your custom views to skip code or show sample data when shown in the IDE.If this is an unexpected error you can also
try to build the project, then manually refresh the layout.Exception Details java.lang.NullPointerException
    at android.content.res.Resources_Delegate.getValue(Resources_Delegate.java: 788)   
    at android.content.res.Resources.getValue(Resources.java: 1286)   
    at android.support.v4.content.res.ResourcesCompat.loadFont(ResourcesCompat.java: 212)   
    at android.support.v4.content.res.ResourcesCompat.getFont(ResourcesCompat.java: 206)   
    at android.support.v7.widget.TintTypedArray.getFont(TintTypedArray.java:119)   
    at android.support.v7.widget.AppCompatTextHelper.updateTypefaceAndStyle(AppCompatTextHelper.java:208)   
    at android.support.v7.widget.AppCompatTextHelper.loadFromAttributes(AppCompatTextHelper.java:152)   
    at android.support.v7.widget.AppCompatTextHelperV17.loadFromAttributes(AppCompatTextHelperV17.java:38)   
    at android.support.v7.widget.AppCompatTextView. < init > (AppCompatTextView.java:81)   
    at android.support.v7.widget.AppCompatTextView. < init > (AppCompatTextView.java: 71)   
    at java.lang.reflect.Constructor.newInstance(Constructor.java: 423)   
    at android.view.LayoutInflater.onCreateView(LayoutInflater.java:717)   
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:785)   
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)   
    at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java: 858)   
    at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)   
    at android.view.LayoutInflater.rInflate(LayoutInflater.java: 834)   
    at android.view.LayoutInflater.inflate(LayoutInflater.java: 492)   
    at com.android.layoutlib.bridge.bars.CustomBar. < init > (CustomBar.java:95)   
    at com.android.layoutlib.bridge.bars.StatusBar. < init > (StatusBar.java: 67)   
    at com.android.layoutlib.bridge.impl.Layout.createStatusBar(Layout.java: 224)   
    at com.android.layoutlib.bridge.impl.Layout. < init > (Layout.java: 146)
mrogal.ski
  • 5,828
  • 1
  • 21
  • 30
Kenyon Tan
  • 111
  • 1
  • 6

2 Answers2

8

This appears to be a bug: Preview render problem when adding maven.google.com as a maven repo.

It is triggered if the new maven repo is used within the project level build.gradle:

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

Unfortunately, we don't seem to have another source for the most recent support library versions (26 and above) since they are apparently not present in the SDK Manager any more:

The support libraries are now available through Google's Maven repository. We no longer support downloading the libraries through the SDK Manager, and that functionality will be removed soon.

All of that said, this problem seems only to affect the designer in Android Studio. You should be able to build and run the app even though the designer complains.

What you apparently won't be able to do is see a nice, quick preview of your layout's TextView elements.

Finally, the designer preview does not seem to have this particular bug in Android Studio v3, which is currently in beta. So, you might want to upgrade and see how that works for you.

albert c braun
  • 2,650
  • 1
  • 22
  • 32
  • Yes this was the reason for the layout rendering issues ! – Sharp Edge Sep 29 '17 at 05:47
  • I am facing the same issue. I was using ad mob integration for this I added maven line in gradle file as it was mentioned in documentation. As soon as I added above maven code and dependency in gradle file I started facing issue and if remove maven and ad repository from gradle it works fine. What can be done if I want to use ad mob dependency? – Abdul Waheed Nov 18 '17 at 15:41
  • I suggest trying it with Android Studio 3. But, if this problem still occurs in Android Studio 3, then please comment back about that. – albert c braun Nov 18 '17 at 17:20
1

Refer this answer here. Updating the current theme parent to Base theme in styles.xml seems working.

SKR
  • 21
  • 4