I\'m trying to set up a connection between Android Wear and an Android phone. The googleApiClient fails to connect, and returns a SERVICE_VERSION_UPDATE_REQUIRED status code
Android Wear requires you have Google Play services version >= 5.0.89 installed on your phone
You can check your version and update the Play Services APK here: https://play.google.com/store/apps/details?id=com.google.android.gms&hl=en
Also Useful:
Important: Because it is hard to anticipate the state of each device, you must always check for a compatible Google Play services APK before you access Google Play services features. For many apps, the best time to check is during the onResume() method of the main activity.
Code to check if Play Services is available (on your phone):
// ########################################################################
// Check if Google Play Services is installed. If not show error dialog.
int result = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if( ConnectionResult.SUCCESS == result ){
mGoogleApiClient.connect();
loadingTextView.setText("Connecting to Wear...");
}
else {
// Show appropriate dialog
Dialog d = GooglePlayServicesUtil.getErrorDialog(result, this, 0);
d.show();
}
More details here:
https://developer.android.com/google/play-services/setup.html#ensure
Looks like putting the googleClient.connect() on onStart() solves the issue:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
// Build a new GoogleApiClient
checkIfGoogleApiClientExists();
googleClient = new GoogleApiClient.Builder(this)
.addApi(Wearable.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
}
@Override
protected void onStart() {
Log.i(LOG_TAG,"entered onStart");
super.onStart();
googleClient.connect();
}