I'm trying to setup a Google Wear app, so on my mobile side, I'm trying to create a GoogleApiClient that uses the Wearable API, but I get an error saying I need to update (SERVICE_VERSION_UPDATE_REQUIRED). But my phone is already at the latest version of Google Play Services. I used the standard Android Studio create wizard to create an app with a wear app, and this is my main activity (and I also added "" to the Manifest.
import android.app.Activity;
import android.app.Dialog;
import android.os.Bundle;
import android.util.Log;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.wearable.Wearable;
public class MyActivity extends Activity
implements
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener {
private GoogleApiClient mGoogleApiClient;
private String TAG = "MyApp";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Wearable.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
}
@Override
protected void onStart() {
super.onStart();
mGoogleApiClient.connect();
}
@Override //ConnectionCallbacks
public void onConnected(Bundle connectionHint) {
Log.d(TAG, "Google API Client was connected");
}
@Override //ConnectionCallbacks
public void onConnectionSuspended(int cause) {
Log.d(TAG, "Connection to Google API client was suspended");
}
@Override //OnConnectionFailedListener
public void onConnectionFailed(ConnectionResult result) {
Log.d(TAG, "FAILED TO CONNECT");
Dialog d = GooglePlayServicesUtil.getErrorDialog(result.getErrorCode(), this, 0);
d.show();
}
}
I had this problem recently on Eclipse (not sure if this is a problem on Android Studio, but give it a try if you haven't solved it yet). The only solution I found was to use an older version of the Google Play Services library in my Wear project.
The latest version of the library (as of today, it's 7095000) does not work with the emulator you can create using Eclipse. So I reverted to an older version I had (version 6587000) and the GoogleApiClient
now connects just fine.
If you don't have an older version, check out this answer which links to several earlier versions. The latest you can get there is version 6171000 (download link). It's slightly older than the one I have but it should work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With