Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GoogleApiClient fails for Android Wear API requires update but I'm already updated

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();
    }
}
like image 345
bryan Avatar asked Sep 20 '14 17:09

bryan


1 Answers

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.

like image 129
Ricardo Avatar answered Nov 20 '22 01:11

Ricardo