title: BootstrapApplication cannot be cast to ApplicationClass
body: <p>I'm running the new stable release of Android Studio ver 2.0. When I disable instant run my app runs fine, but when I turn it on it gives me this error: </p>
  
  <pre><code>Caused by: java.lang.ClassCastException: com.android.tools.fd.runtime.BootstrapApplication cannot be cast to com.my.app.CustomApplication
  </code></pre>
  
  <p>CustomApplication is an Application class that I get through a context. But I can't seem to get it. When instant run is on, my class is cast as BootstrapApplication then fails.</p>
  
  <p>My app is a floating service like FB chatheads.</p>
  
  <p>I have the latest gradle build:</p>
  
  <pre><code>classpath 'com.android.tools.build:gradle:2.0.0'
  </code></pre>
  
  <p>Other answers here say that instant Run tries to do hot swapping of code; this causes the application class to be moved.</p>
  
  <p>So how can I get around this?</p>