10

I have recently updated to com.google.android.gms:play-services 9.2.0 and am attempting to use the new Chromecast library and Firebase Analytics but am receiving the error "com.google.android.gms.internal.zzsj$zza: No acceptable module found. Local version is 0 and remote version is 0." in the Activity onCreate method at com.google.android.gms.cast.framework.CastContext.(Unknown Source). Any ideas if this is due to the Cast functionality not working with the emulators or if it's a version issue? The emulators I am testing with are running 5.0 and 5.1.

    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    FirebaseAnalytics mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
    setupCastListener();
    mCastContext = CastContext.getSharedInstance(this);
    mCastSession = mCastContext.getSessionManager().getCurrentCastSession();
    mCastContext.getSessionManager().addSessionManagerListener(mSessionManagerListener, CastSession.class);
    mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
}

Thanks

Jaz
  • 371
  • 1
  • 6
  • 20
  • I got error message that "No acceptable module found. Local version is 0 and remote version is 0" , i add run-time permission and problem solved. – varotariya vajsi Feb 04 '18 at 10:29

3 Answers3

11

The version of Play Services on your emulator does not support 9.2.0. At this time, I don't think any of the emulator images support 9.2.0. Your options are to downgrade to 9.0.2, or run on a real device until an updated emulator image is released.

If you look carefully at your logcat output you should see a message like this:

W/GooglePlayServicesUtil: Google Play services out of date.  Requires 9256000 but found 9080030

You can see the GPS version number the emulator is using by going to Settings/Apps, finding Google Play Services, and tapping on it to get the App Info.

You can get the GPS version number from code by calling GoogleApiAvalability.GOOGLE_PLAY_SERVICES_VERSION_CODE.

This answer contains some related information about emulator versions.

Update for Adrian Cretu's questions regarding real devices

My experiments indicate that it is possible for a Cast app running on a real device to detect an older version of Play Services and initiate resolution processing. I experimented with the CastVideos sample app. My solution may not be the best, but demonstrates the concept. I created a new activity that runs on launch and checks the availability of Play Services. I changed the manifest to make this activity the launcher activity instead of VideoBrowserActivity:

public class InitActivity extends AppCompatActivity {
    private static final String TAG = "InitActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        GoogleApiAvailability googAvail = GoogleApiAvailability.getInstance();

        int status = googAvail.isGooglePlayServicesAvailable(this);
        Log.i(TAG, "onCreate: Status= " + googAvail.getErrorString(status));

        googAvail.makeGooglePlayServicesAvailable(this)
                .addOnCompleteListener(new OnCompleteListener<Void>() {
            @Override
            public void onComplete(@NonNull Task<Void> task) {
                Log.i(TAG, "onComplete: Done");
                if (task.isSuccessful()) {
                    Log.i(TAG, "onComplete: Starting VideoBrowser");
                    startActivity(new Intent(InitActivity.this, VideoBrowserActivity.class));
                    finish();
                } else {
                    Log.e(TAG, "onComplete: RESOLUTION FAILED");
                }
            }
        });
    }
}

If Play Services is present, up to date, and enabled, the task that checks for availability completes immediately and starts VideoBrowserActivity, the original launch activity. Otherwise, a dialog is presented telling the user that Play Services must be upgraded, and after the user accepts, the Play Store is opened and the user can initiate a download of the latest version.

I was unable to find a way to cleanly transition back to the VideoBrowserActivity. I had to restart the app. With more work, I think a clean recovery from out-of-date Play Services is possible. At least something better than an app crash.

Community
  • 1
  • 1
Bob Snyder
  • 37,759
  • 6
  • 111
  • 158
  • Thanks qbix. Maybe I should re-think using this version for a bit. Too bad the cast functionality was much improved. – Jaz Jul 07 '16 at 18:27
  • 1
    Thanks for the sample. After some digging it appears the crash occurs when CastContext.getSharedInstance() is called, which I'm actually calling from a Service. Your approach, while perfectly valid, is not at all developer-friendly. Cast v2 was a pain exactly because of the entire Google API client boiler-plate: connection flow, errors, callbacks, and user resolutions such as opening activities and waiting for the results, all for just calling loadMedia of a simple URL... I guess deleting all those hundreds of lines of code and switching to v3 was not a good idea. – Adrian Crețu Jul 09 '16 at 13:57
  • Sounds like a significant issue that deserves a separate question. Although Google claims that updates to Play Services are pushed out to phones in a few days, there will always be cases where a device does not the latest version. – Bob Snyder Jul 09 '16 at 15:07
1

This crash also happens on real devices with non-updated GPS. I am using Google Cast SDK v3 and GPS 9.2.0

I didn't see anywhere mentioned that the device actually requires GPS 9.2.0 in order for the Cast v3 to work. What is the workaround or at least a solution for the app not to crash on startup?

Adrian Crețu
  • 878
  • 8
  • 17
  • I think the only solution is for users to upgrade to the new upgrade play services and handle the errors unfortunately. – Jaz Jul 08 '16 at 19:54
  • I don't use Cast and am not familiar with its dependencies. In general, it is possible to use the methods in [GoogleApiAvailability](https://developers.google.com/android/reference/com/google/android/gms/common/GoogleApiAvailability) to resolve problems with Play Services not being present or not updated to a needed version. I recall there is a guide on how to do this in the documentation but can't find it. You might find some examples or more info if you search for it. – Bob Snyder Jul 08 '16 at 20:10
  • @qbix - the Cast SDK v3 explicitly doesn't require any interaction with GPS client availability as a feature for simplified usage. The exception occurs before the activity is even created, so there's no actual hook to override and check availability, etc; unfortunately because now is over-simplified to work behind the scenes, the app just crashes when the latest GPS is not present. Looks like a bug to me more than a feature. – Adrian Crețu Jul 08 '16 at 23:30
  • I updated my answer in response to your comments. I hope my experiments were with Cast SDK v3. I'll check that now. – Bob Snyder Jul 09 '16 at 04:51
0

When I updated the google play developer services app, I was able to solve it.

Blue
  • 22,608
  • 7
  • 62
  • 92