title: NullPointerException ContextCompat Error
body: <p>I have created a custom component ,which on adding to the layout i get the following error</p>
  
  <p>Error is as follows</p>
  
  <pre><code>java.lang.NullPointerException
      at android.support.v4.content.ContextCompatApi21.getDrawable(ContextCompatApi21.java:26)
      at android.support.v4.content.ContextCompat.getDrawable(ContextCompat.java:321)
      at com.test.digitalexperience.widget.testTicketLoaderWidget.createDrawables(testTicketLoaderWidget.java:101)
      at com.test.digitalexperience.widget.testTicketLoaderWidget.init(testTicketLoaderWidget.java:69)
      at com.test.digitalexperience.widget.testTicketLoaderWidget.&lt;init&gt;(testTicketLoaderWidget.java:52)
      at com.test.digitalexperience.widget.testTicketLoaderWidget.&lt;init&gt;(testTicketLoaderWidget.java:44)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
      at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
      at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
      at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:465)
      at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:172)
      at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:105)
      at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:170)
      at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:247)
      at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:171)
      at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
      at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:835)
      at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
      at android.view.LayoutInflater.rInflate(LayoutInflater.java:811)
      at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
      at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
      at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:223)
      at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:426)
      at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:350)
      at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:510)
      at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:498)
      at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:967)
      at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:498)
      at com.android.tools.idea.rendering.RenderTask.access$600(RenderTask.java:72)
      at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:610)
      at com.android.tools.idea.rendering.RenderTask$3.call(RenderTask.java:607)
      at com.android.tools.idea.rendering.RenderService.runRenderAction(RenderService.java:359)
      at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:607)
      at com.android.tools.idea.rendering.RenderTask.render(RenderTask.java:629)
      at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.doRender(AndroidLayoutPreviewToolWindowManager.java:652)
      at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager.access$1700(AndroidLayoutPreviewToolWindowManager.java:80)
      at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7$1.run(AndroidLayoutPreviewToolWindowManager.java:594)
      at com.intellij.openapi.progress.impl.CoreProgressManager$2.run(CoreProgressManager.java:142)
      at com.intellij.openapi.progress.impl.CoreProgressManager.registerIndicatorAndRun(CoreProgressManager.java:446)
      at com.intellij.openapi.progress.impl.CoreProgressManager.executeProcessUnderProgress(CoreProgressManager.java:392)
      at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:54)
      at com.intellij.openapi.progress.impl.CoreProgressManager.runProcess(CoreProgressManager.java:127)
      at org.jetbrains.android.uipreview.AndroidLayoutPreviewToolWindowManager$7.run(AndroidLayoutPreviewToolWindowManager.java:589)
      at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:337)
      at com.intellij.util.ui.update.MergingUpdateQueue.execute(MergingUpdateQueue.java:327)
      at com.intellij.util.ui.update.MergingUpdateQueue$3.run(MergingUpdateQueue.java:271)
      at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:286)
      at com.intellij.util.ui.update.MergingUpdateQueue.flush(MergingUpdateQueue.java:244)
      at com.intellij.util.ui.update.MergingUpdateQueue.run(MergingUpdateQueue.java:234)
      at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
      at com.intellij.util.Alarm$Request$1.run(Alarm.java:352)
      at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
      at java.util.concurrent.FutureTask.run(FutureTask.java:262)
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      at java.lang.Thread.run(Thread.java:745)
  </code></pre>
  
  <p>In my java class i have imported</p>
  
  <pre><code>android.support.v4.content.ContextCompat;
  </code></pre>
  
  <p>In dependencies i have added</p>
  
  <pre><code>dependencies {
      compile 'com.android.support:appcompat-v7:23.1.0'    
  }
  </code></pre>
  
  <p>and i am using gradle version</p>
  
  <pre><code>com.android.tools.build:gradle:2.0.0
  </code></pre>
  
  <p>custom component widget code</p>
  
  <p><a href="http://pastebin.com/nWn46qA3" rel="nofollow">http://pastebin.com/nWn46qA3</a></p>