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

  • Home
  • SEARCH
  • 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 8410177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:06:34+00:00 2026-06-10T00:06:34+00:00

Possible Duplicate: Android RuntimeException: Unable to instantiate the service I am trying to run

  • 0

Possible Duplicate:
Android RuntimeException: Unable to instantiate the service

I am trying to run this GCMIntentService code but I keep getting Unable to instantiate service. Here is my GCMIntentService code:

package com.e;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences.Editor;
import android.util.Log;

import com.google.android.gcm.GCMBaseIntentService;

public class GCMIntentService extends GCMBaseIntentService {
  public static String TAG = "GCMIntentService";
  private static String KEY = "c2dmPref";
  private static String REGISTRATION_KEY = "registrationKey";

  public GCMIntentService(String senderId) {
    super(senderId);
    Log.d("GCMIntentService", senderId);
  }

  @Override
  public void onRegistered(Context context, String regId){
    Log.e("registration :","registration :"+regId);

    if (regId != null) {
        Log.d("c2dm", regId);
        Editor editor = context.getSharedPreferences(KEY, Context.MODE_PRIVATE).edit();
        editor.putString(REGISTRATION_KEY, regId);
        editor.commit();
    }
  }

  @Override
  public void onMessage(Context context, Intent intent){
     String message = intent.getExtras().getString("payload");
     //String key = intent.getExtras().getString("collapse_key");
     Log.e("","message : " +message);    
          Intent startActivity = new Intent(); 
            startActivity.setClass(context, NotificationService.class); 
            startActivity.setAction(NotificationService.class.getName()); 
            startActivity.setFlags( 
                    Intent.FLAG_ACTIVITY_NEW_TASK 
                    | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);      
            startActivity.putExtra("Title", "New Message");
            startActivity.putExtra("Message", message);
            context.startActivity(startActivity); 
  }

  @Override
  protected void onError(Context arg0, String arg1) {
    Log.d("onError", arg1);
  }

  @Override
  protected boolean onRecoverableError(Context context, String errorId){
    Log.d("onRecoverableError", errorId);
    return false;
  }

  @Override
  protected void onUnregistered(Context arg0, String arg1) {
    // TODO Auto-generated method stub
     Log.d("onUnregistered", arg1);
  }

}

And here is my manifest

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

<application android:icon="@drawable/mainlogo" android:label="@string/app_name">                
    <activity android:name=".SplashScreen" android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".HomeScreen"></activity>
    <activity android:name=".TabController" android:windowSoftInputMode="adjustPan"></activity>
    <activity android:name=".Help" android:windowSoftInputMode="adjustPan"></activity>
    <activity android:name=".Services"></activity>
    <activity android:name=".About"></activity>
    <activity android:name=".Inbox"></activity>
    <activity android:name=".More"></activity>
    <activity android:name=".Disclaimer"></activity>
    <activity android:name=".Legal"></activity>
    <activity android:name=".PrivacyPolicy"></activity>
    <activity android:name=".Settings"></activity>
    <activity android:name=".TermsOfUse"></activity>
    <activity android:name=".WebPage"></activity>
    <activity android:name=".DetailView"></activity>
    <service android:name=".NotificationService"></service>
    <service android: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="com.e" />
        </intent-filter>
    </receiver> 
</application>

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

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<uses-sdk android:minSdkVersion="10" />
</manifest>

LogCat

 08-16 16:18:29.026: E/AndroidRuntime(651): FATAL EXCEPTION: main
 08-16 16:18:29.026: E/AndroidRuntime(651): java.lang.RuntimeException: Unable to instantiate service com.e.GCMIntentService: java.lang.InstantiationException: com.e.GCMIntentService
 08-16 16:18:29.026: E/AndroidRuntime(651):     at android.app.ActivityThread.handleCreateService(ActivityThread.java:1929)
 08-16 16:18:29.026: E/AndroidRuntime(651):     at android.app.ActivityThread.access$2500(ActivityThread.java:117)
 08-16 16:18:29.026: E/AndroidRuntime(651):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:985)
08-16 16:18:29.026: E/AndroidRuntime(651):  at android.os.Handler.dispatchMessage(Handler.java:99)
08-16 16:18:29.026: E/AndroidRuntime(651):  at android.os.Looper.loop(Looper.java:130)
08-16 16:18:29.026: E/AndroidRuntime(651):  at android.app.ActivityThread.main(ActivityThread.java:3683)
08-16 16:18:29.026: E/AndroidRuntime(651):  at java.lang.reflect.Method.invokeNative(Native Method)
08-16 16:18:29.026: E/AndroidRuntime(651):  at java.lang.reflect.Method.invoke(Method.java:507)
08-16 16:18:29.026: E/AndroidRuntime(651):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-16 16:18:29.026: E/AndroidRuntime(651):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-16 16:18:29.026: E/AndroidRuntime(651):  at dalvik.system.NativeStart.main(Native Method)
08-16 16:18:29.026: E/AndroidRuntime(651): Caused by: java.lang.InstantiationException: com.e.GCMIntentService
08-16 16:18:29.026: E/AndroidRuntime(651):  at java.lang.Class.newInstanceImpl(Native Method)
08-16 16:18:29.026: E/AndroidRuntime(651):  at java.lang.Class.newInstance(Class.java:1409)
08-16 16:18:29.026: E/AndroidRuntime(651):  at android.app.ActivityThread.handleCreateService(ActivityThread.java:1926)
08-16 16:18:29.026: E/AndroidRuntime(651):  ... 10 more
  • 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-10T00:06:35+00:00Added an answer on June 10, 2026 at 12:06 am

    Unable to instantiate service is called by some Exception being thrown in the constructor. There is usually a stack trace that accompanies this (which you should have included), but you should NOT be using a constructor with a String parameter.

    You must define this sender ID yourself:

    private final static String senderID = "11111111111"; // Your ID here
    
    public GCMIntentService(){
        super(senderID);
        Logd.i(LOG_TAG, "GCM passed");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Android RuntimeException: Unable to instantiate the service Trying to get GCM up
Possible Duplicate: Android RuntimeException: Unable to instantiate the service Problem: starting an IntentService generates
Possible Duplicate: Android RuntimeException: Unable to instantiate the service I am downloading my data
Possible Duplicate: Android AdMobs problem. I am trying to put in an ad but
Possible Duplicate: how to call RESTful web service from android? This is my web
Possible Duplicate: Android findViewbyId with a variant string I have this type of code
Possible Duplicate: Slow Android emulator I am trying to run an android application in
Possible Duplicate: Android: trouble updating to Android SDK Tools, revision 7 I'm trying to
Possible Duplicate: Why does Android app run in small window on tablet emulator? i
Possible Duplicate: Android: How can I get the current foreground activity (from a service)?

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.