title: Android Studio the following class could not be instantiated?
body: <p>I am getting the error <code>android.support.v7.widget.Toolbar in Eclipse could not be instantiated</code> I am working on Android Studio 1.2.1.1 following the tutorial <a href="http://www.android4devs.com/2014/12/how-to-make-material-design-navigation-drawer.html" rel="nofollow">here</a> I have tried a couple of tips from different help pages searching on Google and Stackoverflow but none works for me. First I switched my android version to 22 but still got the error. Please note that when using version 22, I extended class <code>AppCombatActivity</code> Here is my Exception details when using version 22.</p>
  
  <pre><code>java.lang.ClassNotFoundException: android.support.v7.appcompat.R$attr
  at org.jetbrains.android.uipreview.ModuleClassLoader.load(ModuleClassLoader.java:127)
  at com.android.tools.idea.rendering.RenderClassLoader.findClass(RenderClassLoader.java:53)
  at org.jetbrains.android.uipreview.ModuleClassLoader.findClass(ModuleClassLoader.java:84)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  at android.support.v7.widget.Toolbar.&lt;init&gt;(Toolbar.java:192)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
  at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:413)
  at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)
  at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:177)
  at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:214)
  at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:142)
  at android.view.LayoutInflater_Delegate.parseInclude(LayoutInflater_Delegate.java:117)
  at android.view.LayoutInflater.parseInclude(LayoutInflater.java:858)
  at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:802)
  at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
  at android.view.LayoutInflater.rInflate(LayoutInflater.java:782)
  at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:809)
  at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
  at android.view.LayoutInflater.rInflate(LayoutInflater.java:782)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
  at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:413)
  at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:321)
  at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
  at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:497)
  at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:485)
  at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:894)
  at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:485)
  at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:590)
  at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$6.run(AndroidDesignerEditorPanel.java:480)
  at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
  at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
  at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
  at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
  at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
  at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
  at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
  at com.intellij.util.Alarm$Request$1.run(Alarm.java:351)
  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p>When I set to Android version to 21, I receive same error plus one more where <code>android.support.v7.widget.RecyclerView in Eclipse could not be instantiated</code></p>
  
  <pre><code>java.lang.UnsupportedOperationException: Unsupported Service: accessibility
  at com.android.layoutlib.bridge.android.BridgeContext.getSystemService(BridgeContext.java:463)
  at android.support.v7.widget.RecyclerView.&lt;init&gt;(RecyclerView.java:302)
  at android.support.v7.widget.RecyclerView.&lt;init&gt;(RecyclerView.java:278)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
  at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:413)
  at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)
  at com.android.tools.idea.rendering.LayoutlibCallback.loadView(LayoutlibCallback.java:177)
  at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
  at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:132)
  at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:806)
  at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
  at android.view.LayoutInflater.rInflate(LayoutInflater.java:782)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
  at android.view.LayoutInflater.inflate(LayoutInflater.java:385)
  at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:400)
  at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:332)
  at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
  at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:497)
  at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:485)
  at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:894)
  at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:485)
  at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:590)
  at com.intellij.android.designer.designSurface.AndroidDesignerEditorPanel$6.run(AndroidDesignerEditorPanel.java:480)
  at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:320)
  at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:310)
  at com.intellij.util.ui.update.MergingUpdateQueue$2.run(MergingUpdateQueue.java:254)
  at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:269)
  at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:227)
  at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:217)
  at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
  at com.intellij.util.Alarm$Request$1.run(Alarm.java:351)
  at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
  at java.util.concurrent.FutureTask.run(FutureTask.java:266)
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
  at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p>I have also Invalidate cache and restarted my Android Studio. I have also tried extending class Activity but still the same error persists.</p>
  
  <p>Here is my Main Activity XML</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  </code></pre>
  
  <p>
  
  <pre><code>xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/DrawerLayout"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:elevation="7dp"&gt;
  
  
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"&gt;
  
  
      &lt;include
          android:id="@+id/tool_bar"
          layout="@layout/tool_bar"&gt;
      &lt;/include&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Hello World" /&gt;
  
  &lt;/LinearLayout&gt;
  
  
  &lt;android.support.v7.widget.RecyclerView
      android:id="@+id/RecyclerView"
      android:layout_width="320dp"
      android:layout_height="match_parent"
      android:layout_gravity="left"
  
      android:background="#ffffff"
      android:scrollbars="vertical"&gt;
  
  &lt;/android.support.v7.widget.RecyclerView&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here is my tool_bar.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:background="@color/ColorPrimary"
      android:elevation="4dp"
  
      &gt;
  
  &lt;/android.support.v7.widget.Toolbar&gt;
  </code></pre>
  
  <p>Here is my Gradle file</p>
  
  <pre><code>dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.1.1'
    compile 'de.hdodenhof:circleimageview:1.2.1'
    compile 'com.android.support:recyclerview-v7:21.0.+'
  }
  </code></pre>
  
  <p>All other files are the same as the ones on the tutorial except that I removed the <code>&lt;span&gt;&lt;/span&gt;</code> element. How can I fix this error?</p>