GCM:java.lang.noclassdeffounderror:com.google.android.gcm.GCMRegistrar [英] GCM : java.lang.noclassdeffounderror: com.google.android.gcm.GCMRegistrar

查看:18
本文介绍了GCM:java.lang.noclassdeffounderror:com.google.android.gcm.GCMRegistrar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用以下代码将设备注册到 GCM:

I am trying to register a device onto GCM using the following code:

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);


    GCMRegistrar.checkDevice(this);
    // the following function can be removed when deploying the app
    GCMRegistrar.checkManifest(this);

    final String regId = GCMRegistrar.getRegistrationId(this);
    if (regId.equals("")) {
      GCMRegistrar.register(this, SENDER_ID);
    } else {
      Log.v(TAG, "Already registered");
    } 

我已经导入了 import com.google.android.gcm.GCMRegistrar;
并且还将 GCM.jar 添加到我在 Eclipse 中的构建路径中,这是我通过 sdk 下载获得的

I have imported import com.google.android.gcm.GCMRegistrar;
and also added GCM.jar to my buildpath in Eclipse which i got thru the sdk download

请帮忙!

推荐答案

在更新的 ADT(Above ADT 17) 中,您必须将 jar 文件放在 libs 文件夹中,而不是 lib.因此,请确保将 gcm.jar 文件放在 libs 而不是 lib 文件夹中.

In the updated ADT(Above ADT 17) you have to put jar files inside libs folder and not lib. So make sure that you put gcm.jar file inside libs and not lib folder.

这篇关于GCM:java.lang.noclassdeffounderror:com.google.android.gcm.GCMRegistrar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆