由于错误代码无法连接到GoogleApiClient:SERVICE_VERSION_UPDATE_REQUIRED

时间:2015-12-22 00:05:39

标签: android google-play-services avd

我正在Andriod Studio上开发,我创建了一个类似GoogleApiClient的实例:

locationClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(LocationServices.API)
                .build();

我有一个像这样的onConnectionFailed处理程序:

@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
    if (connectionResult.hasResolution()) {
        try {
            connectionResult.startResolutionForResult(ACTRequest.this, 6);
        } catch (IntentSender.SendIntentException e) {
        }
    } else {
        //Connection failure cannot be resolved
        Toast.makeText(getApplicationContext(),
                "Unable to connect to Google Service, sorry >_<" + connectionResult.getErrorMessage(), Toast.LENGTH_LONG)
                .show();
        Log.d("CONNECTION FAIL", connectionResult.getErrorCode() + " Unable to connect to Google Service, sorry >_<");
    }
}

每次运行此活动时,都会收到错误代码:2 = SERVICE_VERSION_UPDATE_REQUIRED

要解决此问题,我在android studio上安装了Google Play Service修订版29.0.0,并确保我的模拟器具有API23。但是,我仍然收到这个错误。

我不知道此时该怎么做,我怎样才能在我的模拟器上更新google play服务?我的代码有问题吗?

解决方法:

感谢您推荐2.0模拟器!以下是我发现解决这个问题的另一种方法:

由于在模拟器上更新Google Play服务非常困难,因此我们可以在构建项目时将google-services的gradle依赖项中的版本降低到1.5.0-beta1:

dependencies {
    classpath 'com.android.tools.build:gradle:1.3.1'
    classpath 'com.google.gms:google-services:1.5.0-beta1'
}

并使用:

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

但不建议这样做。

1 个答案:

答案 0 :(得分:0)

要使用此模拟器,请使用当前预览中的新模拟器2.0版:http://tools.android.com/tech-docs/emulator

相关问题