I create a class:

public class RegistrationService extends IntentService { public RegistrationService() { super("RegistrationService"); } String TAG = "MyLog"; @Override protected void onHandleIntent(Intent intent) { Log.i(TAG, "11"); InstanceID myID = InstanceID.getInstance(this); Log.i(TAG, "22"); try { Log.i(TAG, "33"); String registrationToken = myID.getToken( getString(R.string.gcm_defaultSenderId), GoogleCloudMessaging.INSTANCE_ID_SCOPE, null ); Log.d("Registration Token", registrationToken); GcmPubSub subscription = GcmPubSub.getInstance(this); subscription.subscribe(registrationToken, "/topics/my_little_topic", null); } catch (IOException e) { e.printStackTrace(); } } } 

At the moment

 InstanceID myID = InstanceID.getInstance(this); 

application falls. Where should I look for a problem?

Here is the error log:

 12-28 20:46:35.825 1381-1381/? E/ActivityThread: Service com.android.email.service.EmailBroadcastProcessorService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@31bcfd1 that was originally bound here android.app.ServiceConnectionLeaked: Service com.android.email.service.EmailBroadcastProcessorService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@31bcfd1 that was originally bound here at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:1336) at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:1231) at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1478) at android.app.ContextImpl.bindService(ContextImpl.java:1450) at android.content.ContextWrapper.bindService(ContextWrapper.java:636) at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:181) at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:224) at com.android.email.service.EmailServiceUtils.isServiceAvailable(EmailServiceUtils.java:160) at com.android.email.provider.AccountReconciler.reconcileAccountsInternal(AccountReconciler.java:171) at com.android.email.provider.AccountReconciler.reconcileAccounts(AccountReconciler.java:115) at com.android.email.service.EmailBroadcastProcessorService.reconcileAndStartServices(EmailBroadcastProcessorService.java:305) at com.android.email.service.EmailBroadcastProcessorService.onBootCompleted(EmailBroadcastProcessorService.java:295) at com.android.email.service.EmailBroadcastProcessorService.onHandleIntent(EmailBroadcastProcessorService.java:130) at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:67) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.os.HandlerThread.run(HandlerThread.java:61) 12-28 20:46:35.829 631-992/system_process I/ActivityManager: Start proc 1421:com.android.messaging/u0a59 for broadcast com.android.messaging/.receiver.BootAndPackageReplacedReceiver 
  • To use FCM, you need an uncommon service. Read the instructions - mit

0