title: Getting Google Cast v3 to work on unsupported devices
body: <p>The Cast V3 framework has features which try to make it possible to run on devices without the <code>Google Play Services</code> required for it to work, but I ran into some issues when testing.</p>
  
  <ol>
  <li>On the Kindle the Google API returns SERVICE_INVALID with a isUserResolvable() true.</li>
  <li>On devices with the onActivityResult returning <code>ConnectionResult.SUCCESS</code> after upgrade, the <code>CastContext.getSharedInstance()</code> can throw <code>RuntimeError</code>.</li>
  <li>As a side-effect of 2), the XML inflate of items containing <code>MiniControllerFragment</code> will fail.</li>
  </ol>
  
  <p>Some errors I found were</p>
  
  <pre><code>java.lang.RuntimeException: Unable to start activity ComponentInfo{##########.MainActivity}: android.view.InflateException: Binary XML file line #42: Error inflating class fragment
  
  Caused by: java.lang.RuntimeException: 
    com.google.android.gms.dynamite.DynamiteModule$zzc: Remote load failed. No local fallback found.
      at com.google.android.gms.internal.zzauj.zzan(Unknown Source)
      at com.google.android.gms.internal.zzauj.zza(Unknown Source)
      at com.google.android.gms.cast.framework.CastContext.&lt;init&gt;(Unknown Source)
      at com.google.android.gms.cast.framework.CastContext.getSharedInstance(Unknown Source)
      at com.google.android.gms.cast.framework.media.uicontroller.UIMediaController.&lt;init&gt;(Unknown Source)
      at com.google.android.gms.cast.framework.media.widget.MiniControllerFragment.onCreateView(Unknown Source)
  </code></pre>
  
  <p>This was caused by the inflation of the MiniControllerFragment, on a device where the <code>CastController</code> code wasn't installed.  This is similar to the question asked <a href="https://stackoverflow.com/questions/39313189/google-cast-sdk3-android-sample-app-is-crashing-on-device-below-5-0">SO : Cast v3 is crashing on devices below 5.0</a>.  The answer provided by Kamil Ślesiński helped in my investigation.</p>
  
  <p>and </p>
  
  <pre><code>java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=123, result=0, data=null} to activity #####
  </code></pre>
  
  <p>When I had implemented my ViewStub, I was still crashing in the pre-release test machines, as they were returning SUCCESS, but didn't have the CastContext available.  To fix this, I needed another test to check if the CastContext was creatable.</p>