Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat Is The Error In This GCM Code
    text
    copied!<p>I am Trying to register the Device in the cloud (Google Cloud Messaging <strong>GCM</strong>)</p> <p>but some Error facing the application </p> <p>can you help me on this</p> <p>Here's My Manifest</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.test09_gsm" android:versionCode="1" android:versionName="1.0" &gt; &lt;uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17" /&gt; &lt;permission android:name="com.example.test09_gsm.permission.C2D_MESSAGE" android:protectionLevel="signature" /&gt; &lt;uses-permission android:name="com.example.test09_gsme.permission.C2D_MESSAGE" /&gt; &lt;uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /&gt; &lt;uses-permission android:name="android.permission.INTERNET" /&gt; &lt;uses-permission android:name="android.permission.GET_ACCOUNTS" /&gt; &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt; &lt;application android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme" &gt; &lt;activity android:name="com.example.test09_gsm.MainActivity" android:label="@string/app_name" &gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.LAUNCHER" /&gt; &lt;/intent-filter&gt; &lt;/activity&gt; &lt;receiver android:name="com.google.android.gcm.GCMBroadcastReceiver" android:permission="com.google.android.c2dm.permission.SEND" &gt; &lt;intent-filter&gt; &lt;action android:name="com.google.android.c2dm.intent.RECEIVE" /&gt; &lt;action android:name="com.google.android.c2dm.intent.REGISTRATION" /&gt; &lt;category android:name="com.example.test09_gsm" /&gt; &lt;/intent-filter&gt; &lt;/receiver&gt; &lt;service android:name=".GCMIntentService" /&gt; &lt;/application&gt; &lt;/manifest&gt; </code></pre> <p>Hers's The Class</p> <pre><code>package com.example.test09_gsm; import com.google.android.gcm.GCMBaseIntentService; import android.content.Context; import android.content.Intent; import android.util.Log; public class GCMIntentService extends GCMBaseIntentService { public static String TAG = "GCMIntentService"; public GCMIntentService(String senderId) { super(senderId); Log.d("GCMIntentService", senderId); } @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 onMessage(Context arg0, Intent arg1) { Log.d("onMessage", String.valueOf(arg1)); } @Override protected void onRegistered(Context arg0, String arg1) { Log.d("onRegistered", arg1); } @Override protected void onUnregistered(Context arg0, String arg1) { Log.d("onUnregistered", arg1); } } </code></pre> <p>Main Activity</p> <pre><code>package com.example.test09_gsm; import com.google.android.gcm.GCMRegistrar; import android.os.Bundle; import android.app.Activity; import android.util.Log; import android.view.Menu; public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GCMRegistrar.checkDevice(this); GCMRegistrar.checkManifest(this); final String regId = GCMRegistrar.getRegistrationId(this); if (regId.equals("")) { GCMRegistrar.register(this, "XXXXXXXXXXXX"); } else { Log.v("Info : ", "Already registered"); } } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.activity_main, menu); return true; } } </code></pre> <p>LogCat</p> <pre><code>12-15 00:28:28.935: E/Trace(4569): error opening trace file: No such file or directory (2) 12-15 00:28:29.085: D/GCMRegistrar(4569): resetting backoff for com.example.test09_gsm 12-15 00:28:29.085: V/GCMRegistrar(4569): Registering app com.example.test09_gsm of senders XXXXXXXXXXXX 12-15 00:28:29.160: D/libEGL(4569): loaded /system/lib/egl/libEGL_mali.so 12-15 00:28:29.165: D/libEGL(4569): loaded /system/lib/egl/libGLESv1_CM_mali.so 12-15 00:28:29.165: D/libEGL(4569): loaded /system/lib/egl/libGLESv2_mali.so 12-15 00:28:29.170: D/(4569): Device driver API match 12-15 00:28:29.170: D/(4569): Device driver API version: 10 12-15 00:28:29.170: D/(4569): User space API version: 10 12-15 00:28:29.170: D/(4569): mali: REVISION=Linux-r2p4-02rel0 BUILD_DATE=Wed Sep 12 17:53:53 KST 2012 12-15 00:28:29.205: D/OpenGLRenderer(4569): Enabling debug mode 0 12-15 00:28:29.985: V/GCMBroadcastReceiver(4569): onReceive: com.google.android.c2dm.intent.REGISTRATION 12-15 00:28:29.985: V/GCMBroadcastReceiver(4569): GCM IntentService class: com.example.test09_gsm.GCMIntentService 12-15 00:28:29.985: V/GCMBaseIntentService(4569): Acquiring wakelock 12-15 00:28:30.000: D/dalvikvm(4569): newInstance failed: no &lt;init&gt;() 12-15 00:28:30.000: D/AndroidRuntime(4569): Shutting down VM 12-15 00:28:30.000: W/dalvikvm(4569): threadid=1: thread exiting with uncaught exception (group=0x40e372a0) 12-15 00:28:30.000: E/AndroidRuntime(4569): FATAL EXCEPTION: main 12-15 00:28:30.000: E/AndroidRuntime(4569): java.lang.RuntimeException: Unable to instantiate service com.example.test09_gsm.GCMIntentService: java.lang.InstantiationException: can't instantiate class com.example.test09_gsm.GCMIntentService; no empty constructor 12-15 00:28:30.000: E/AndroidRuntime(4569): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2388) 12-15 00:28:30.000: E/AndroidRuntime(4569): at android.app.ActivityThread.access$1600(ActivityThread.java:140) 12-15 00:28:30.000: E/AndroidRuntime(4569): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1309) 12-15 00:28:30.000: E/AndroidRuntime(4569): at android.os.Handler.dispatchMessage(Handler.java:99) 12-15 00:28:30.000: E/AndroidRuntime(4569): at android.os.Looper.loop(Looper.java:137) 12-15 00:28:30.000: E/AndroidRuntime(4569): at android.app.ActivityThread.main(ActivityThread.java:4898) 12-15 00:28:30.000: E/AndroidRuntime(4569): at java.lang.reflect.Method.invokeNative(Native Method) 12-15 00:28:30.000: E/AndroidRuntime(4569): at java.lang.reflect.Method.invoke(Method.java:511) 12-15 00:28:30.000: E/AndroidRuntime(4569): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008) 12-15 00:28:30.000: E/AndroidRuntime(4569): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775) 12-15 00:28:30.000: E/AndroidRuntime(4569): at dalvik.system.NativeStart.main(Native Method) 12-15 00:28:30.000: E/AndroidRuntime(4569): Caused by: java.lang.InstantiationException: can't instantiate class com.example.test09_gsm.GCMIntentService; no empty constructor 12-15 00:28:30.000: E/AndroidRuntime(4569): at java.lang.Class.newInstanceImpl(Native Method) 12-15 00:28:30.000: E/AndroidRuntime(4569): at java.lang.Class.newInstance(Class.java:1319) 12-15 00:28:30.000: E/AndroidRuntime(4569): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2385) 12-15 00:28:30.000: E/AndroidRuntime(4569): ... 10 more </code></pre> <p>now how can i resolve this problem and receive the registration ID And Use it </p> <p>thanks in advance</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload