2

I am getting the following error in Android Studio layout preview :

Rendering Problems The following classes could not be found:android.support.v7.widget.Toolbar (Fix Build Path, Create Class)
Tip: Try to build the project."

I am using Android Studio 1.3 Preview 3 release. with buildToolsVersion "21.1.2", com.android.tools.build:gradle:1.3.0-beta1", compileSdkVersion 21.

The App builds successfully and runs perfectly on my phone though. How can solve this issue? Note that the problem is NOT of instantiation as pointed by the possible duplicate. The issue is only in rendering, the App builds and runs without issues.

random40154443
  • 1,100
  • 1
  • 10
  • 25
  • possible duplicate of [The following classes could not be instantiated: - android.support.v7.widget.Toolbar](http://stackoverflow.com/questions/26575815/the-following-classes-could-not-be-instantiated-android-support-v7-widget-too) – Lamorak Jun 11 '15 at 15:46

3 Answers3

1

Go to styles.xml, you can found there something like

<style name="AppBaseTheme" parent="Theme.AppCompat.Light.Darkactionbar">

Add "Base." before "Theme", to

<style name="AppBaseTheme" parent="Base.Theme.AppCompat.Light.Darkactionbar">

it's something like a bug in Android Studio

AterLux
  • 4,566
  • 2
  • 10
  • 13
0

Add dependency for the AppCompat library in your app's build.gradle file:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
}

Note that the version number 22.0.0 depends on the latest support library found in your android sdk for the appCompat library

blueware
  • 5,205
  • 1
  • 40
  • 60
0

I had a similar issue. What worked for me was to change the API to a lower version, I am using the 21 for exemple.
On the layout preview screen, there is a tinny Bugdroid, click on him then choise your API version. you might also want to unclick the Automically Pick Best option.
Hope it helped !

Bastien Viatge
  • 315
  • 3
  • 15