alfo888_ibg
alfo888_ibg

Reputation: 1857

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

Please help, it's all the days that I work on this problem and used all possible solutions found on the web.

Requirements: Use juno eclipse, ADT 20 I have works with business GCM, I did a project a bit more complicated using the demo of Android developers (http://developer.android.com/guide/google/gcm/demo.html) And I realized that my application was in Crask each call class GCMRegistrar.

So I created a minimal exercise that will work if I unlock everything.

import com.google.android.gcm.GCMRegistrar;

    public class Manda extends Activity {

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_manda);

        crash --->  GCMRegistrar.checkDevice(this);

            // while developing the app, then uncomment it when it's ready.

            GCMRegistrar.checkManifest(this);

        }

I attach the screenshot of the min exercise I added the gcm.jar library and I did all I found.

I am a new user than I can not post img but I put a public link of bropbox https://www.dropbox.com/s/dyi0y4sppz4rcq3/img%20GCM%20problem.zip

Upvotes: 2

Views: 7116

Answers (3)

alfo888_ibg
alfo888_ibg

Reputation: 1857

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).

Upvotes: 0

Passion
Passion

Reputation: 662

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!

Upvotes: 0

Givi
Givi

Reputation: 3283

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

Upvotes: 1

Related Questions