The following classes could not be instantiated: - android.support.v7.widget.Toolbar

the following classes could not be instantiated androidx constraintlayout widget constraintlayout
the following classes could not be instantiated android studio
failed to instantiate one or more classes
the following classes could not be found android support design widget textinputlayout
the following classes could not be instantiated com google android material card materialcardview
missing classes error in android studio
recyclerview failed to instantiate
android.support.v7.widget.toolbar not found

I am creating an app with the new Material Design used in Android Lollipop (5.0).

I am using the following guides:

After I create my toolbar, I receive this error: "The following classes could not be instantiated: - android.support.v7.widget.Toolbar"

The app works well in the phone or emulator, but the layout designer of Android Studio doesn't show the layout correctly.

Here there are some images:

Error in my_awesome_toolbar.xml layout preview

Error in activity_my.xml layout preview

The xml code of the files:

my_awesome_toolbar.xml:

<?xml version="1.0" encoding="utf-8"?>

<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/my_awesome_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary" />

activity_my.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/root"
            tools:context="com.myapp.test.MyActivity"
            android:orientation="horizontal">

    <include
        android:id="@+id/toolbar"
        layout="@layout/my_awesome_toolbar"
        />
    <!-- Rest of layout -->
</RelativeLayout>

MyActivity.java:

package com.myapp.test;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;


public class MyActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my);

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.my, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

xml code of the styles (values/styles.xml):

<resources>

    <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
        <item name="colorPrimary">@color/blue</item>
        <item name="colorPrimaryDark">@color/dark_blue</item>
        <item name="actionOverflowButtonStyle">@style/AppTheme.OverflowButtonStyle</item>
    </style>

    <!-- Style Title -->
    <style name="Title">
        <item name="android:textColor">@color/white</item>
        <item name="android:textStyle">bold</item>
        <item name="android:textSize">16sp</item>
    </style>

    <style name="AppTheme.OverflowButtonStyle" parent="Widget.AppCompat.ActionButton.Overflow">
        <item name="android:src">@drawable/overflow_icon</item>
    </style>
</resources>

At the moment I use Android Studio Beta 0.8.9


For Android Studio (or IntelliJ IDEA),

If everything looks OK in your project and that you're still receiving the error in all your layouts, try to 'Invalidate caches & restart'.

Wait until Android Studio has finished to create all the caches & indexes.

The following classes could not be instantiated android.support.v7 , 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  The following classes could not be instantiated: #168. asdasdasdasdasdasdasdad opened this issue Sep 13, 2017 · 3 comments Comments. Copy link Quote reply


I changed the res/values/styles.xml file from this:

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

to this:

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

and that solved the problem.

How to fix "The following classes could not be instantiated" in , Rendering Problems The following classes could not be instantiated. I'm getting this when i'm setting up android studio and trying to run the  The following classes could not be instantiated: - android.support.design.widget.TextInputLayout #1 komalnikhare opened this issue Nov 26, 2015 · 3 comments Comments


I did what @gbero said, and I changed the Android version number that Studio uses from 22 to 17 and it works.

I am using the backwards compatibility to build for Android ver 22 but to target 17 (idk if that's correctly said, I am still trying to figure this app stuff out) so that triggered the backwards compatibility, which afaik is what the android.support.v7.* is. This is probably a bug with their rendering code. Not sure if clearing the cache as suggested above was needed as rendering didn't work just after invalidating the cache, it started working after I changed the version to render. If I change back to version 22, the rendering breaks, if I switch back to 17, it works again.

Rendering Problems The following classes could not be instantiated , Failed to instantiate one or more classes : The following class could not be instantiated :- -android.support.v7.widget.RecyclerView(Open class  Rendering Problems: The following classes could not be instantiated: - com.roughike.bottombar.BottomBar what am i missing or what do i need to do, to solve my problem? (already tried the exact code as stated in the tutorial)


From: https://stackoverflow.com/a/29989542/4123403

  1. Clean project
  2. Rebuild project
  3. Sync Gradle

This did the trick for me.

Failed to instantiate RecyclerView, I get the following error. Failed to load AppCompat ActionBar with unknown error. The following classes could not be instantiated:. This video shows how to fix a common problem in Android Studio in Rendering the Preview Rendering Problems The Following classes could not be found : android.support.v7.internal.widget.


Another mistake that can have the same effect can be the wrong theme in the preview. For some reason I had selected some other theme here. After choosing my AppTheme it worked fine again:

Failed to load AppCompat ActionBar with unknown error, Hey Guys, so I've compiled: 'com.roughike:bottom-bar:2.0.2' defined my tabs in the xml file: res/xml/bottombar_tabs.xml with the drawables. and  The following classes could not be found: - android.support.v7.internal.widget.ActionBarOverlayLayout. If someone can tell me what can I do to fix this rendering problem? Thank you.


Rendering Problems: The following classes could not be instantiated, The following classes could not be instantiated: - com.rilixtech.​CountryCodePicker (Open Class, Show Exception, Clear Cache) Tip: Use View. The following classes could not be instantiated: - android.support.v7.internal.widget.ActionBarOverlayLayout (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 Exception Details


Rendering Issue: The following classes could not be instantiated , Rendering Problems The following classes could not be found: - android.support.​v7.internal.app.WindowDecorActionBar (Fix Build Path, Create Class) Tip: Try to​  Rendering Problems The following classes could not be instantiated: - android.support.design.widget.CoordinatorLayout (Open Class, Show Exception, Clear Cache) Tip: Use View.isInEditMode ()


Error rendering,