![](/img/trans.png)
[英]java.lang.NoClassDefFoundError: Failed resolution Failed resolution of: Lcom/google/android/gms/common/internal/zzab;
[英]java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/common/GooglePlayServicesUtil
我正在尝试运行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 ,到目前为止我已完成以下操作:
我已经做了很多次,现在一直在寻找解决方案,这让我发疯了。 请帮忙!!! :(
PS:我正在使用物理设备进行测试,在我的LG G3和Galaxy S4上进行了测试。
我一直在尝试很多解决方案,最后我来解决问题。 解决方案如下。
在“\\ eclipse \\ eclipse.ini”中更改您的VM值,如下所示:
打开文件
--launcher.XXMaxPermSize
512M
-showsplash
org.eclipse.platform
--launcher.defaultAction
打开文件
-vmargs
-Dosgi.requiredJavaVersion = 1.5
-Xms512m
-Xmx1024m
按照https://developer.android.com/google/play-services/setup.html设置并将“google-play-services_lib”引用到您的项目中。 最终输出应该如下图所示:
我希望这个解决方案可以帮助其他Android开发者,因为它让我感到沮丧,因为我遵循谷歌的指南,但应用程序不断崩溃:D
干杯
检查您的设备是否安装了Google Play服务应用,并且其版本与您项目中安装的版本相同。
另外,检查清单文件中的minSDK和TargetSDK是否超过或超出API级别。
不要错过Manifest中的这个标签:
<application
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
</application>
要测试Google Play服务,您需要在安装了Google Play服务的物理设备上运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.