"No acceptable module found" on Android emulators using com.google.android.gms play-services 9.2.0

Jaz picture Jaz · Jul 7, 2016 · Viewed 14k times · Source

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

Answer

Bob Snyder picture Bob Snyder · Jul 7, 2016

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.