GCM: java.lang.NoClassDefFoundError: com.google.android.gcm.GCMRegistrar

女生的网名这么多〃 提交于 2019-12-06 12:58:04

As stated in Google's docs, you MUST add your AndroidManifast.xml file the following:

<service android:name="YOUR.PACKAGE.NAME.GCMIntentService" />

<receiver
            android:name="com.google.android.gcm.GCMBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />

                <category android:name="YOUR_CATEGORY_NAME" />
            </intent-filter>
        </receiver>

Make sure you put your IntentService class in the right package.

In addition, how did you add the gcm.jar to you project? You need to create a "libs" folder in your project and put the jar there

Solution 1:

  1. Check that you have put gcm.jar file inside libs and not lib folder.

Solution 2:

Mostly this is the problem.Follow below steps to resolve the problem:

  1. Right click on Project->Build Path-> Configure Build Path and then Order and Exports
  2. Now check the Android Private Libraries .The checkbox should check of required library.
  3. Refresh ,Clean and Run..here you go!

The problem was my emulator without Google Apis (Google Inc). If you are using android emulator you have to create emulator with Google Apis (Google Inc).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!