title: ActivityManager: Unable to start service Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x1000010 (has extras) } U=0: not found
body: <p>Since trying to update my Android application from Eclipse over to Android Studio (converting to a gradle project) I've been running into issues. I think I've smoothed over most of them, but I am unable to get notifications from GCM (which is an important part of the application).</p>
  
  <p>Here is the message I from the Android phone getting the GCM message (these messages are posted from a server multi casting to multiple android devices):</p>
  
  <pre><code>    --------- beginning of main
  2018-10-26 15:46:36.222 2921-2921/com.ddv.android.gcm.support.app V/GCMBroadcastReceiver: onReceive: com.google.android.c2dm.intent.RECEIVE
  2018-10-26 15:46:36.222 2921-2921/com.ddv.android.gcm.support.app V/GCMBroadcastReceiver: GCM IntentService class: com.ddv.android.gcm.support.app.GCMIntentService
  2018-10-26 15:46:36.225 2921-2921/com.ddv.android.gcm.support.app V/GCMBaseIntentService: Acquiring wakelock
  2018-10-26 15:46:36.226 1686-3213/? W/ActivityManager: Unable to start service Intent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10 pkg=com.ddv.android.gcm.support.app cmp=com.ddv.android.gcm.support.app/com.activate.gcm.GCMIntentService (has extras) } U=0: not found
  </code></pre>
  
  <p>Here's my AndroidManifest.xml</p>
  
  <pre><code>&lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.ddv.android.gcm.support.app"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  ...
  &lt;permission
          android:name="com.ddv.android.gcm.support.app.permission.C2D_MESSAGE"
          android:protectionLevel="signature" /&gt;
  
      &lt;uses-permission android:name="com.ddv.android.gcm.support.app.permission.C2D_MESSAGE" /&gt;
  
      &lt;!-- This app has permission to register and receive data message. --&gt;
      &lt;uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" /&gt;
      &lt;uses-permission android:name="com.ddv.android.gcm.support.app.permission.RECEIVE" /&gt;
  ...
      &lt;application
          android:icon="@drawable/ddv_launcher"
          android:label="@string/app_name"
          android:theme="@style/PulseAppTheme" 
          android:allowBackup="false"
          android:name=".GlobalVariables" &gt;
          &lt;receiver
              android:name="com.google.android.gcm.GCMBroadcastReceiver"
              android:enabled="true"
              android:exported="true"
              android:permission="com.google.android.c2dm.permission.SEND" &gt;
              &lt;intent-filter&gt;
  
                  &lt;!-- Receives the actual messages. --&gt;
                  &lt;action android:name="com.google.android.c2dm.intent.RECEIVE" /&gt;
                  &lt;!-- Receives the registration id. --&gt;
                  &lt;action android:name="com.google.android.c2dm.intent.REGISTRATION" /&gt;
  
                  &lt;category android:name="com.ddv.android.gcm.support.app" /&gt;
              &lt;/intent-filter&gt;
          &lt;/receiver&gt;
  
          &lt;service android:name="com.ddv.android.gcm.support.app.GCMIntentService"
              android:enabled="true"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="com.google.android.c2dm.intent.RECEIVE" /&gt;
              &lt;/intent-filter&gt;
          &lt;/service&gt;
  ...
  </code></pre>
  
  <p>I have also tried changing the <code>&lt;service android:name="com.ddv.android.gcm.support.app.GCMIntentService"</code> to <code>&lt;service android:name=".GCMIntentService"</code> with the same results.</p>
  
  <p>Basically what I can tell is that the Android device is getting the GCM message. And it knows that the GXM IntentService is my custom com.ddv.android.gcm.support.app.GCMIntentService, but it's not doing anything with it... And it's not really throwing any error. The message i see in the logcat just looks like a warning if anything.</p>
  
  <p>I've made sure my GCMIntentService is in the main package of the application. And that I have all the correct permissions so I'm not sure what I'm missing or why I can't get this to work.</p>
  
  <p>I did have to change how my GCM registers when I updated my application and it's possible I still have this incorrect. But the following code is not throwing any errors and when I send out the GCM message from the server all of my Android devices get the message from above (making it look like they are registered correctly and getting something from Google).</p>
  
  <p>GCM registration code:</p>
  
  <pre><code>if (gcm == null) {
      gcm = GoogleCloudMessaging.getInstance(RegisterActivity.this);
  }
  regId = gcm.register(SENDER_ID);
  Log.d(TAG, "########################################");
  Log.d(TAG, "Current Device's Registration ID is: " + regId);
  SharedPreferences prefs = RegisterActivity.this.getSharedPreferences("com.google.android.gcm", 0);
  SharedPreferences.Editor editor = prefs.edit();
  editor.putString("regId", regId);
  editor.apply();
  Log.d(TAG, "prefs.getString(\"regId\", \"\"): " + prefs.getString("regId", ""));
  Log.d(TAG, "GCMRegistrar.getRegistrationId: " + GCMRegistrar.getRegistrationId(RegisterActivity.this));
  ServerUtilities.registerToGCMServer(RegisterActivity.this, regId);
  </code></pre>
  
  <p>ServerUtilities code:</p>
  
  <pre><code>static boolean registerToGCMServer(final Context context, final String regId) {
      Log.i(TAG, "registering device on GCM Server (regId = " + regId + ")");
      String baseUrl = getHost(context) + context.getString(R.string.GCM_PATH) + context.getString(R.string.GCM_REGISTER_PATH);
      Map&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
      params.put("regId", regId);
      long backoff = BACKOFF_MILLI_SECONDS + random.nextInt(1000);
      // Once GCM returns a registration id, we need to register it in the
      // demo server. As the server might be down, we will retry it a couple
      // times.
      for (int i = 1; i &lt;= MAX_ATTEMPTS; i++) {
          Log.d(TAG, "Attempt #" + i + " to register");
          try {
              displayMessage(context, context.getString(R.string.server_registering, i, MAX_ATTEMPTS));
              post(baseUrl, params);
              GCMRegistrar.setRegisteredOnServer(context, true);
              String message = context.getString(R.string.server_registered);
              CommonUtilities.displayMessage(context, message);
              return true;
          } catch (IOException e) {
              // Here we are simplifying and retrying on any error; in a real
              // application, it should retry only on unrecoverable errors
              // (like HTTP error code 503).
              Log.e(TAG, "Failed to register on attempt " + i, e);
              if (i == MAX_ATTEMPTS) {
                  break;
              }
              try {
                  Log.d(TAG, "Sleeping for " + backoff + " ms before retry");
                  Thread.sleep(backoff);
              } catch (InterruptedException e1) {
                  // Activity finished before we complete - exit.
                  Log.d(TAG, "Thread interrupted: abort remaining retries!");
                  Thread.currentThread().interrupt();
                  return false;
              }
              // increase backoff exponentially
              backoff *= 2;
          }
      }
      String message = context.getString(R.string.server_register_error, MAX_ATTEMPTS);
      CommonUtilities.displayMessage(context, message);
      return false;
  }
  </code></pre>
  
  <p>Oh right final piece of info. Here is what I am expecting for my application to do: in my <code>GCMIntentService.java</code> I'm expecting the overwritten <code>onMessage()</code> function to be called which displays an alert based on the GCM message received.</p>
  
  <pre><code>public class GCMIntentService extends GCMBaseIntentService {
  ...
      @Override
      public void onMessage(Context context, Intent intent) {
          Log.i(TAG, "Received message");
          String alertText = intent.getExtras().getString("text");
          String ackID = intent.getExtras().getString("id");
          String detailID = intent.getExtras().getString("detail_id");
  
          // Sets the class to be called when the notification is selected
          intent.setClass(context, AlertFragmentActivity.class);
          intent.putExtra("alert", (Parcelable) (new Alert(ackID, detailID, alertText)));
  
          // I think this only goes through if the app is already running?
          displayAlert(context, intent);
          // notifies user
          generateNotification(context, intent);
      }
  }
  </code></pre>
  
  <p>I know I'll eventually have to update to FCM, but this should still be working in the mean time (till April 2019 when GCM gets completely removed).</p>