2

I am testing android wear app on Wear Emulator and using eclipse to develop.

In wear app there are code as below in onCreate:

mGoogleApiClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this).addOnConnectionFailedListener(new GoogleApiClient.OnConnectionFailedListener()
{
    @Override
    public void onConnectionFailed(ConnectionResult result)
    {
    Log.d(TAG, "onConnectionFailed: " + result);
    }
}).addApi(Wearable.API).build();
mGoogleApiClient.connect();

When I run this on Wear emulator I got error as below:

W/GooglePlayServicesUtil(1809): Google Play services out of date.  Requires 5089000 but found 5077534
D/WearApp(1809): onConnectionFailed: ConnectionResult{statusCode=SERVICE_VERSION_UPDATE_REQUIRED, resolution=null}

If any one have solution or tips for that then please let me know.

Thanks!

Kalpesh
  • 1,767
  • 19
  • 29

2 Answers2

-1

I believe I had the same error.

If your build.gradle is:

compile 'com.google.android.gms:play-services:+'

change it to:

compile 'com.google.android.gms:play-services:5.0.89'

that's because Google didn't completely roll out the latest play services to devices, but it's already available to developers. As an alternative solution, you can check if there's an update to the WearEmulator on the SDK Manager.

Budius
  • 39,391
  • 16
  • 102
  • 144
  • Hi Budius, I am using eclipse to develop, I am not finding build.gradle, where are do above change? – Kalpesh Sep 05 '14 at 12:41
  • That's the `build.gradle` that is exclusive to IntelliJ or AndroidStydio, there's been more than an year I don't use Eclipse, but I don't think there's a comparable action to it. But I believe it's worth checking the SDK Manager for updates on the Wear Emulator image. – Budius Sep 05 '14 at 12:43
  • I checked the SDK Manager for updates on the Wear Emulator image. But it's show me up to date... – Kalpesh Sep 05 '14 at 12:46
  • Ok np, Thanks for your attention :-) – Kalpesh Sep 05 '14 at 12:48
  • This is not correct. You should not use play-services to build an APK for a wearable. The + symbol is fine, and if you add -wearable to the name it will fix everything correctly. See my answer above. – Wayne Piekarski Sep 10 '14 at 18:31
  • @WaynePiekarski Apparently you didn't read the comments of me talking with the OP and just loves to down vote. First because we had a talk and we both agree it's not correct and i wished him good luck. And second because you didn't notice that he's not using gradle and your answer is also wrong. – Budius Sep 10 '14 at 20:31
  • My answer mentions that you need to manually unpack the AAR if you are using Eclipse. The important thing is that you must use play-services-wearable and not play-services on a wearable device, or you will get the error message that the OP asked about. In the past, if you got these mixed up, it would still accidentally work, but over time the versions have changed and this is now important and we are starting to see these kinds of questions pop up. – Wayne Piekarski Sep 11 '14 at 00:23
-2

If you look in your build.gradle file, you are probably using play-services. You need to use play-services-wearable instead, which has the correct version.

compile 'com.google.android.gms:play-services-wearable:+'

If you are using Eclipse, you need to ensure you unpack the play-services-wearable AAR file and not the standard mobile play-services AAR file.

Wayne Piekarski
  • 3,203
  • 18
  • 19
  • @ Wayne Piekarski Where are find build.gradle file in eclipse project? – Kalpesh Sep 10 '14 at 05:15
  • There is no build.gradle with Eclipse. But in order to use Eclipse, you would have followed some steps to take the AAR file and unpack it. Make sure you unpack play-services-wearable and not play-services. – Wayne Piekarski Sep 10 '14 at 18:31
  • I just unpack wearable-1.0.0.aar and used in project as take reference from http://goo.gl/mNBwvs . And using google-play-services-lib simple not unpack any play-services-wearable. If this is needed then please can you suggest something to get play-services-wearable ? – Kalpesh Sep 11 '14 at 06:47
  • @Kalpesh: the link you referenced above talks about how to add play-services to your phone app, and adding the wearable support library to your wearable app. But it does not cover how to do play-services-wearable for your wearable app. If you go to your Android SDK there is a file ./extras/google/m2repository/com/google/android/gms/play-services-wearable/5.0.77/play-services-wearable-5.0.77.aar which contains what you need. If you unzip this file, it contains classes.jar which has the code you need to link in, and a variety of resources that are probably not needed. – Wayne Piekarski Sep 11 '14 at 18:23
  • @Kalpesh: if you are just getting started, it is definitely recommended that you switch to Android Studio, which makes this stuff *so* much easier, and is the future for Android development. – Wayne Piekarski Sep 11 '14 at 18:23