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

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.


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.

how to invalidate cache & restart


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.

my fix


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

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

This did the trick for me.


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:

layout options