GooglePlayServicesUtil: Google Play服务已过期。需要5089000,但发现5077534。

3
我遇到了一个与google-play-services SDK的更新相关的问题。我的应用程序可以构建和运行(就像以前一样),但是在Android Wear手表上,日志中会显示以下消息:
GooglePlayServicesUtil:Google Play服务过时。需要5089000版本,但发现只有5077534。
因此,该应用程序使用5.0.89版本进行编译,但手表仅有5.0.77版本。由于此原因,手表与手机之间的通信失败了(此前可以使用)。
如何使应用程序向后兼容google-play-services的早期版本,因为Android Studio没有提供返回早期版本google-play-services的方法?
以下是wear应用程序的gradle设置。
dependencies {
   compile 'com.google.android.gms:play-services:5.0.+@aar'
   compile "com.android.support:support-v13:20.0.+"
   compile "com.google.android.support:wearable:1.0.+"
}

如果我尝试强制使用版本5.0.77,Android Studio在构建过程中会出错:

错误:找不到com.google.android.gms:play-services:5.0.77

我该如何保持与早期Google Play服务版本相容,以便支持手表设备?


你尝试过将其强制更新到最新的4.x版本('com.google.android.gms:play-services:4.+')吗?这对我有用,但也许Android Wear的某些功能会丢失。同时,请注意在所有具有Google Play依赖项的应用程序模块的Gradle文件中更改此设置。 - Simon
2个回答

5

可穿戴设备端的build.gradle需要更新为使用play-services-wearable而不是像您上面展示的那样仅使用play-services。

因此,如果您查看Wear SDK提供的DataLayer之类的样本,它在wearable/build.gradle中使用类似于以下内容:

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

我已经提出请求,希望很快能在官方文档中提到这一点。


如果我在Eclipse中遇到相同的问题怎么办?我应该如何解决它? - Warlax
@Warlax:你之前在Eclipse上是怎么让play-services在可穿戴设备上运行的? - Wayne Piekarski

3
当您的手机使用旧版play-service而您正在使用新版play-service库时,就会出现这种情况。因此,您需要从手机上更新您的google-play-service。
您可以使用:
int googleServiceStatus = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
    Dialog dialog = GoogleApiAvailability.getInstance().getErrorDialog(this,googleServiceStatus, 10);
    if(dialog!=null){
        dialog.show();
    }

如果在获取play-service时出现任何问题,这将显示弹出窗口。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接