15

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.

8
  • Please file a bug: issuetracker.google.com/… Commented Oct 11, 2017 at 15:38
  • I have the same bug only happening on Nexus and Samsung devices and it happens when I call: CastButtonFactory.setUpMediaRouteButton(getApplicationContext(), btnCast); Any new updates on this issue?
    – yalematta
    Commented Oct 18, 2017 at 8:51
  • @yalematta No updates.
    – sam_k
    Commented Oct 18, 2017 at 17:05
  • issuetracker.google.com/issues/65359941
    – sam_k
    Commented Jan 31, 2018 at 16:03
  • 2
    Having this problem on alot of Huawei devices
    – mco
    Commented May 17, 2018 at 21:40

2 Answers 2

4

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;
  }
}
1
  • 1
    What am I missing within the code block? The second isAvailable function doesn't have a comment to say what class it's part of or if it's like "option 2"; it also doesn't return. Commented Aug 24, 2021 at 16:59
-1

I get this issue when play services are out of date (mainly on emulators running API 24). This worked for me:

GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();

int resultCode = googleApiAvailability.isGooglePlayServicesAvailable(this);

if (resultCode == ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED) {
        googleApiAvailability.getErrorDialog(this, resultCode, 1000).show();
        return;
}
startApp();

I run this code in an Activity which checks if MainActivity should be started

3
  • We all are getting the result : ConnectionResult.SUCCESS, not ConnectionResult.SERVICE_VERSION_UPDATE_REQUIRED.
    – sam_k
    Commented Oct 23, 2017 at 17:07
  • Even when it crashes? Commented Oct 23, 2017 at 17:11
  • Check my updated question. I am getting after I am getting ConnectionResult.SUCCESS==resultCode from googlePlayServicesVerified() method.
    – sam_k
    Commented Oct 23, 2017 at 18:07

Not the answer you're looking for? Browse other questions tagged or ask your own question.