title: App crashes with ClassCastException on Application class testing M backup
body: <p>I'm following the <a href="https://developer.android.com/intl/in/training/backup/autosyncapi.html" rel="nofollow">guide</a> to specify exclusions from full backups but running into a crash when I try and test it.</p>
  
  <pre><code>$ adb shell bmgr fullbackup &lt;PACKAGE&gt;
  </code></pre>
  
  <p>Works fine - files are excluded as expected.</p>
  
  <p>I clear data then run:</p>
  
  <pre><code>$ adb shell bmgr restore &lt;PACKAGE&gt;
  </code></pre>
  
  <p>The restore works fine but then the next time I try and run the app I'm getting a <code>ClassCastException</code>:</p>
  
  <pre><code>Caused by: java.lang.ClassCastException: android.app.Application cannot be cast to com.domain.app.MyCustomApplicationClass
  </code></pre>
  
  <p>It appears that for some reason there is an instance of my application but it's not an instance of the custom application class as specified in the manifest.</p>
  
  <p>Running the app a second time works fine and I can verify that all data was correctly restored.</p>
  
  <p>I am testing this on a debug build and would like to try and resolve this error before pushing the latest changes to production.</p>