I'm trying to run the sample of Google Cloud Messaging, which follows the tutorial from official website https://developer.android.com/google/gcm/client.html . However, the sample suddenly crash and generate the error as following:
After tracing, I found the error in this block of code:
/**
* 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;
}
I've also followed the guide to set up Google Play Service https://developer.android.com/google/play-services/setup.html and I've done the following so far:
I've done this many times and been searching for solution for a few days now, it is driving me crazy. Please HELP!!! :(
PS: I'm using physical device to test, tested on my LG G3 and Galaxy S4.
I've been trying on many solution, finally I've come to my own fix. The solution goes as below.
Change your VM values in "\\eclipse\\eclipse.ini" as below:
openFile
--launcher.XXMaxPermSize
512M
-showsplash
org.eclipse.platform
--launcher.defaultAction
openFile
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms512m
-Xmx1024m
Follow https://developer.android.com/google/play-services/setup.html to set up and reference the "google-play-services_lib" into your project. Final output should be something like the image below:
I hope this solution could help fellow android dev, as it got me frustrated since I followed the guide from google, but the app keep crashing :D
Cheers
Check to see if your device has the Google Play Services app installed and also it has the same version as installed in your project.
Also check the minSDK and TargetSDK in the manifest file does not exceed or precede API levels.
Do not miss this tag in Manifest:
<application
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
要测试Google Play服务,您需要在安装了Google Play服务的物理设备上运行。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.