Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ChromeCast RuntimeException : Remote load failed. No local fallback found

I am using cast feature in my application. It was working fine but suddenly I can see the increase in the number of crashes on play store console.

I am initializing CastContext properly as defined in the guidelines and Moreover, I am checking that device is compatible or not before calling this method CastContext.getSharedInstance(context) So that should not be an issue.

I am not able to reproduce this crash even on emulators with or without google-play-services one.

Any help will be appreciated.

Crash :

Fatal Exception: java.lang.RuntimeException: Unable to start activity ComponentInfo{... .activity.TVActivityPhone}: java.lang.RuntimeException: com.google.android.gms.dynamite.DynamiteModule$zza: Remote load failed. No local fallback found. at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2677) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2747) at android.app.ActivityThread.access$900(ActivityThread.java:187) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1584) at android.os.Handler.dispatchMessage(Handler.java:111) at android.os.Looper.loop(Looper.java:194) at android.app.ActivityThread.main(ActivityThread.java:5877) at java.lang.reflect.Method.invoke(Method.java) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1020) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:815) Caused by java.lang.RuntimeException: com.google.android.gms.dynamite.DynamiteModule$zza: Remote load failed. No local fallback found.

Code I am getting an error inside the if the condition that means, it's not about the google play service availability.

   if (googlePlayServicesVerified(context)) {  // checking (result==ConnectionResult.SUCCES)
      Log.d("TAG", "instantiated");
      castContext = CastContext.getSharedInstance(context);
    } else {
      Log.e(TAG, "FAILED");
    }

Filed bug to google:

https://issuetracker.google.com/issues/65359941

** Update ** Check these two issues :

https://issuetracker.google.com/issues/65359941 https://issuetracker.google.com/issues/79405933

The temporary solution is in my answer.

like image 486
sam_k Avatar asked Oct 11 '17 00:10

sam_k


1 Answers

This is the temporary solution.

1) Your app should always check GPS version before using any Cast APIs

2) Allow CastContext.getSharedInstance() to fail. Probably throw/catch an exception (or alternatively return null).

3) Make sure, you don't break anything if the dynamite module fails to load. There are some UI widgets that are initialized implicitly which calls CastContext.getSharedInstance(), such as MiniControllerFragment. You should avoid letting it crash if dynamite fails to load.

 public static boolean isAvailable(Context context)
    {
        GoogleApiAvailability availability = GoogleApiAvailability.getInstance();

        return isGooglePlayServicesAvailable(context, availability) &&
                isCastContextAvailable(context);
    }

public static boolean isAvailable(Context context) {
  if (googlePlayServicesVerified(context)) {
    try {
      castContext = CastContext.getSharedInstance(context);
      Log.d(TAG, "CastContext instantiated");
    } catch (Exception e) {
      Log.report(e);
      castContext = null;
    }
  } else {
    CrashReporter.report("CastContext FAILED to be instantiated : googlePlayServicesVerified() has failed."));
    castContext = null;
  }
}
like image 150
sam_k Avatar answered Oct 23 '22 08:10

sam_k