谷歌游戏服务过期。需要11011000,但找到10289574。

32

我已经奋斗了一个星期解决这个问题。虽然搜索了类似的主题,但仍然无法解决我的问题。

问题是,当我尝试在Polar m600 Wear或Wear模拟器(Android V 7.1.1和API25)上运行程序时,它们会给出以下消息:“Google Play服务已过期。需要11011000但找到10289574。”

我遵循了Android开发者网站上的“获取上次已知位置”的部分。(链接到该网站:https://developer.android.com/training/location/retrieve-current.html#play-services

以下是我正在使用的MainActivity代码:

public class MainActivity extends Activity {

private FusedLocationProviderClient mFusedLocationClient;
public Location mLastLocation;
private TextView mTextView;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
    stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
        @Override
        public void onLayoutInflated(WatchViewStub stub) {
            mTextView = (TextView) stub.findViewById(R.id.text);
        }
    });

    mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
    if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION)
            != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION)
            != PackageManager.PERMISSION_GRANTED) {
        return;
    }
    mFusedLocationClient.getLastLocation()
            .addOnSuccessListener(this, new OnSuccessListener<Location>() {
                @Override
                public void onSuccess(Location location) {
                    mLastLocation = location;
                    Log.d("Location is:",""+mLastLocation);

                    if (location != null) {

                    }
                }
            });

}
}

这是我的manifest.xml文件。

Translated:

Here's my manifest.xml file.

<uses-feature android:name="android.hardware.type.watch" />

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@android:style/Theme.DeviceDefault">
    <meta-data android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

最后但并非最不重要的是我的 build.gradle 文件。

android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
    applicationId "ims.fhj.at.testnavigators"
    minSdkVersion 21
    targetSdkVersion 25
    versionCode 1
    versionName "1.0"
    multiDexEnabled true
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
     }
  }
 }

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:2.0.3'
compile 'com.google.android.gms:play-services-wearable:11.0.1'
compile 'com.google.android.gms:play-services:11.0.1'}

请查看此链接 https://dev59.com/tFgR5IYBdhLWcg3woebW#41104004 - Sunil Sunny
8个回答

64

创建带有Android版本O - api 26 - x86或Android版本Nougat - api 24 - x86的Nexus 5x模拟器

Nexus 5x

enter image description here

然后在模拟器中点击三个点,这将打开扩展窗口,在那里点击Google Play + 更新。这将把Google Play服务更新到最新版本11.0.55。

enter image description here


5
这就是正确的答案!谢谢。顺便提一下,您需要使用Google帐户登录模拟器以进行更新。 - JCricket
5
穿戴式模拟器在设置中没有“Google Play”选项卡。 - ken
这个答案对我很有帮助,但是如果我们想测试除了Nexus 5X和Nexus 5之外的其他模拟器怎么办?我的意思是其他模拟器的解决方案是什么? - Zulqarnain Mustafa
1
由于我的模拟器中没有此选项,我在Android SDK中更新了Google Play服务。然后它就可以工作了。 - Karan
英雄不只戴斗篷,感谢您先生!即使它没有解决线程的主要问题,我仍然遇到了设备模拟器的问题。 - Damiii
显示剩余2条评论

2

您需要将可穿戴设备gradle文件中的API版本降级。

问题在于您的设备没有最新的Google Play服务应用程序。

要解决这个问题,请更改为以下内容:

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

2

问题出在模拟器上的 Google Play 服务(版本)与 Gradle 文件不匹配。

有两种解决方法:

  1. 通过将 gradle 文件中的 Google Play 服务(版本)降级为模拟器上的 Google Play Services(版本)来消除不匹配。

  2. 升级模拟器上的 Google Play Services


2
如何在模拟器上升级Google Play服务? - shim

2

我的解决方案可能有点奇怪: 前往设置 -> 应用程序 -> 系统应用程序 -> Google Play商店 我的版本号是10xxxxx,这很奇怪,因为我的手表在启动时已更新。所以,我点击了“卸载更新”按钮,版本号变成了11xxxxxx。


1
正如String所写,设备上的Play服务未更新。不幸的是,在WearOS世界中,Play服务可能已经更新了,但是它们在可穿戴设备上并不可用。在这种情况下,您可以使用以下方法进行反应:
GoogleApiAvailability apiAvailability = GoogleApiAvailability.getInstance();
int result = apiAvailability.isGooglePlayServicesAvailable(this);
if (result != ConnectionResult.SUCCESS) {
    ... 
} else {
     apiAvailability.getErrorDialog(this, result, REQUEST_CODE,this).show();
}

0

这是 Wear 多年来一直存在的问题(例如请参见Android Wear Google Play Services)。

最好的解决方案似乎是不使用最新的 Play Services 版本。其中一个选项是找到一个最小版本,看起来可以覆盖您的目标生产设备;在您的情况下,这听起来像是 10.2 范围内的某些内容。或者,选择包含您需要的所有功能的最低版本(我个人正在使用 9.8.0)。

供参考,这里是 Play Services 的发布历史记录:https://developers.google.com/android/guides/releases


0

0
有时候当您传递了错误的 web-client-id 值时,会出现这个错误。
val gso = GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
                .requestIdToken(**web-client-id here**)
                .requestEmail()
                .build()

Use the value in the OAuth client id section indicated Web client (auto created by google service)

使用 OAuth 客户端 ID 部分中指定的 Web 客户端值(由 Google 服务自动创建) 。

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