【发布时间】:2015-08-03 09:31:44
【问题描述】:
我正在尝试运行 Google Cloud Messaging 的示例,该示例遵循官方网站 https://developer.android.com/google/gcm/client.html 的教程。但是,示例突然崩溃并产生如下错误:
经过追踪,发现这块代码的错误:
/**
* Check the device to make sure it has the Google Play Services APK. If
* it doesn't, display a dialog that allows users to download the APK from
* the Google Play Store or enable it in the device's system settings.
*/
private boolean checkPlayServices() {
int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
if (resultCode != ConnectionResult.SUCCESS) {
if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
GooglePlayServicesUtil.getErrorDialog(resultCode, this,
PLAY_SERVICES_RESOLUTION_REQUEST).show();
} else {
Log.i(TAG, "This device is not supported.");
finish();
}
return false;
}
return true;
}
我还按照指南设置了 Google Play 服务https://developer.android.com/google/play-services/setup.html,到目前为止我已经完成了以下操作:
- 将“google-play-services_lib”复制到 Eclipse 工作区。
- 将“google-play-services_lib”引用到示例项目中。
我已经这样做了很多次,并且几天来一直在寻找解决方案,这让我发疯了。请帮忙!!! :(
P.S:我正在使用物理设备进行测试,在我的 LG G3 和 Galaxy S4 上进行了测试。
【问题讨论】:
-
在模拟器或物理设备上运行?
-
哦...我忘了提,物理设备...抱歉试图简化 n 使问题易于理解@JayeshElamgodil
标签: java android eclipse google-cloud-messaging