Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8691901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:12:58+00:00 2026-06-13T00:12:58+00:00

I am working through an example that Google provides for Cloud Messaging. I have

  • 0

I am working through an example that Google provides for Cloud Messaging. I have this code to start with:

    GCMRegistrar.checkDevice(this);
    GCMRegistrar.checkManifest(this);

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

and this code never gets to the GCMRegistrar.checkManifest(this); line.

The exception I was getting was

Unable to instantiate service com.problemio.GCMIntentService: 
java.lang.InstantiationException: com.problemio.GCMIntentService

One thing I had done was to implement my own GCMRegistrar.java class which I got from an example. The reason I added it was that when I didn’t have it, when I tried to use some methods like:

GCMRegistrar.setRetryReceiverClassName(myClass); in the GCMBroadcastReceiver class, I was getting a syntax error that this method is not visible in the GCMRegistrar class.

So I am not sure whether I should import com.google.android.gcm.GCMRegistrar; or if I should just make my own version of it locally. What do you guys suggest?

And when I had it locally, what could be the reason I got the exception:

Unable to instantiate service com.problemio.GCMIntentService:
java.lang.InstantiationException: com.problemio.GCMIntentService

ps – all testing was done on a device and not the simulator.

EDIT:

Here is the latest exception:

java.lang.RuntimeException: Unable to instantiate service com.problemio.GCMIntentService: java.lang.InstantiationException: com.problemio.GCMIntentService
        at android.app.ActivityThread.handleCreateService(ActivityThread.java:2201)
        at android.app.ActivityThread.access$2500(ActivityThread.java:132)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1102)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:150)
        at android.app.ActivityThread.main(ActivityThread.java:4293)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:507)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
        at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.InstantiationException: com.problemio.GCMIntentService
        at java.lang.Class.newInstanceImpl(Native Method)
        at java.lang.Class.newInstance(Class.java:1409)
        at android.app.ActivityThread.handleCreateService(ActivityThread.java:2198)
        ... 10 more
java.lang.InstantiationException: com.problemio.GCMIntentService
        at java.lang.Class.newInstanceImpl(Native Method)
        at java.lang.Class.newInstance(Class.java:1409)
        at android.app.ActivityThread.handleCreateService(ActivityThread.java:2198)
        at android.app.ActivityThread.access$2500(ActivityThread.java:132)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1102)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:150)
        at android.app.ActivityThread.main(ActivityThread.java:4293)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:507)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
        at dalvik.system.NativeStart.main(Native Method)

and here is my latest GCMIntentService:

package com.problemio;

import static com.google.android.gcm.GCMConstants.ERROR_SERVICE_NOT_AVAILABLE;
import static com.google.android.gcm.GCMConstants.EXTRA_ERROR;
import static com.google.android.gcm.GCMConstants.EXTRA_REGISTRATION_ID;
import static com.google.android.gcm.GCMConstants.EXTRA_SPECIAL_MESSAGE;
import static com.google.android.gcm.GCMConstants.EXTRA_TOTAL_DELETED;
import static com.google.android.gcm.GCMConstants.EXTRA_UNREGISTERED;
import static com.google.android.gcm.GCMConstants.INTENT_FROM_GCM_LIBRARY_RETRY;
import static com.google.android.gcm.GCMConstants.INTENT_FROM_GCM_MESSAGE;
import static com.google.android.gcm.GCMConstants.INTENT_FROM_GCM_REGISTRATION_CALLBACK;
import static com.google.android.gcm.GCMConstants.VALUE_DELETED_MESSAGES;

import java.util.Random;
import java.util.concurrent.TimeUnit;

import com.google.android.gcm.GCMBaseIntentService;

import android.app.AlarmManager;
import android.app.IntentService;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.PowerManager;
import android.os.SystemClock;
import android.util.Log;
import android.widget.Toast;

import utils.GCMConstants;

public abstract class GCMIntentService extends GCMBaseIntentService 
{
    public GCMIntentService() 
    {
            super(ProblemioActivity.SENDER_ID);
    }

    @Override
      protected void onRegistered(Context ctxt, String regId) {
        Log.d(getClass().getSimpleName(), "onRegistered: " + regId);
        Toast.makeText(this, regId, Toast.LENGTH_LONG).show();
      }

      @Override
      protected void onUnregistered(Context ctxt, String regId) {
        Log.d(getClass().getSimpleName(), "onUnregistered: " + regId);
      }

      @Override
      protected void onMessage(Context ctxt, Intent message) {
        Bundle extras=message.getExtras();

        for (String key : extras.keySet()) {
          Log.d(getClass().getSimpleName(),
                String.format("onMessage: %s=%s", key,
                              extras.getString(key)));
        }
      }

      @Override
      protected void onError(Context ctxt, String errorMsg) {
        Log.d(getClass().getSimpleName(), "onError: " + errorMsg);
      }

      @Override
      protected boolean onRecoverableError(Context ctxt, String errorMsg) {
        Log.d(getClass().getSimpleName(), "onRecoverableError: " + errorMsg);

        return(true);
      } 
}

Here is my manifest:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.problemio"
    android:versionCode="82"
    android:versionName="2.2.82" >

    <supports-screens  android:largeScreens="true"   android:normalScreens="true"  android:smallScreens="true"/> 

    <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="16"/>
    <!-- <uses-sdk android:minSdkVersion="8" android:targetSdkVersion="xx"/>  -->

    <uses-permission android:name="android.permission.INTERNET" />

    <!-- Required permission to use in-app billing. -->
    <uses-permission android:name="com.android.vending.BILLING" />



    <permission android:name="com.problemio.permission.C2D_MESSAGE" 
        android:protectionLevel="signature" />
    <uses-permission android:name="com.problemio.permission.C2D_MESSAGE" />


    <!-- App receives GCM messages. -->
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /> 
    <!-- GCM requires a Google account. -->
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />
    <!-- Keeps the processor from sleeping when a message is received. -->
    <uses-permission android:name="android.permission.WAKE_LOCK" /> 







    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" 
        android:theme="@style/CustomTheme" 
        android:name="MyApplication"
        android:debuggable="true"
                >

        <!--  For Google Cloud Messaging -->
        <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="com.problemio" />
          </intent-filter>
        </receiver>   

        <service android:name=".GCMIntentService" />
        <!--  End of Google Cloud Messaging -->
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T00:12:59+00:00Added an answer on June 13, 2026 at 12:12 am

    The reason I added it was that when I didn’t have it, when I tried to use some methods like:
    GCMRegistrar.setRetryReceiverClassName(myClass); in the GCMBroadcastReceiver class, I was getting a syntax error that this method is not visible in the GCMRegistrar class.

    That is because there is no such method. You will not find a reference to such a method in the Android developer documentation.

    So I am not sure whether I should import com.google.android.gcm.GCMRegistrar

    Yes, and do not try to use non-existent methods. The JavaDoc for the GCM client library can be found at: http://developer.android.com/guide/google/gcm/client-javadoc/index.html

    Unable to instantiate service com.problemio.GCMIntentService: java.lang.InstantiationException: com.problemio.GCMIntentService

    Because there is a bug in com.problemio.GCMIntentService, such as not having a public zero-argument constructor.

    Here is a sample project that demonstrates the use of the GCM client library: https://github.com/commonsguy/cw-omnibus/tree/master/Push/GCMClient

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working through the NerdDinner ASP.NET MVC 1.0 example. I have it all working
I'm new to Google Apps Script. I'm working my way through some simple example
I am working through the example from https://blogs.oracle.com/arungupta/entry/java_ee_6_and_nosql . Here is a link to
I am new to Backbone and started by working through the Todos example. After
I'm working through Aaron Hillegass' book, specifically the lottery example. I had a question
I'm working through some tutorials and examples of java.util.concurrent package. Usually example authors put
Here's a simple, barebones example of how the code that I'm trying to do
This should be simple, but I'm at a complete loss. I'm working through a
I've found through research on google that that I can read a text file
I've been trying to modify a Google charts example in order to have three

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.