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

3

6

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();
    }
}
Weig answered 20/9, 2014 at 17:17 Comment(0)
A
1

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.

Ashjian answered 21/4, 2015 at 10:49 Comment(0)
D
0

Try updating the Google Play services package from your SDK manager, maybe you don't have the last version for Android Studio and updating the package might do the trick

Doubling answered 8/10, 2014 at 10:34 Comment(0)
P
0

You need to update the wear emulator also, i was also facing the same issue, and it got resolved once i updated my emulator.

Palter answered 2/5, 2016 at 10:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.