由于错误代码无法连接到 GoogleApiClient:SERVICE_VERSION_UPDATE_REQUIRED
Cannot connect to GoogleApiClient due to errorcode: SERVICE_VERSION_UPDATE_REQUIRED
我正在 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 >_<");
}
}
每次 activity 运行时,我都会收到错误代码:2 = SERVICE_VERSION_UPDATE_REQUIRED
为了解决这个问题,我在 android studio 上安装了 Google Play 服务修订版 29.0.0,并确保我的模拟器具有 API23。但是,我仍然收到此错误。
此时我不确定该怎么做,如何更新我的模拟器上的 google 播放服务?我的代码有问题吗?
解决方法:
感谢您推荐 2.0 模拟器!这是我发现解决(某种程度上)这个问题的另一种方法:
由于在模拟器上更新 google 播放服务非常困难,我们可以将 google 服务的 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'
但是不推荐这样做。
要使其与模拟器一起使用,请使用目前处于预览状态的新模拟器 2.0 版:http://tools.android.com/tech-docs/emulator
我正在 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 >_<");
}
}
每次 activity 运行时,我都会收到错误代码:2 = SERVICE_VERSION_UPDATE_REQUIRED
为了解决这个问题,我在 android studio 上安装了 Google Play 服务修订版 29.0.0,并确保我的模拟器具有 API23。但是,我仍然收到此错误。
此时我不确定该怎么做,如何更新我的模拟器上的 google 播放服务?我的代码有问题吗?
解决方法:
感谢您推荐 2.0 模拟器!这是我发现解决(某种程度上)这个问题的另一种方法:
由于在模拟器上更新 google 播放服务非常困难,我们可以将 google 服务的 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'
但是不推荐这样做。
要使其与模拟器一起使用,请使用目前处于预览状态的新模拟器 2.0 版:http://tools.android.com/tech-docs/emulator