I cannot receive any FCM message anymore in background application
<p>I cannot receive any data message anymore in my application when it's in background.
Notice that it worked perfectly in my application until very recently. Maybe it stopped working after recent updates in my development environment, I can't say....</p>

<p>So I tried to make the test with the <a href="https://github.com/firebase/quickstart-android" rel="nofollow">quickstart-android project</a>, to see it works better.</p>

<p>And the answer is no!</p>

<p>I have no doubt that quickstart-android project is well configured to use FCM capabilities...</p>

<p>I send the following message from Advanced REST Client, I used it successfully to test my application currently published.</p>

<pre><code>{
  "to" : "dLN4paNl3uw:APA91bH0lpkEMxGp...._7EdxkB2cRbPKFxT2Ti3OPw-7fCSwXCSfGG",
  "data": {
    "id": 19,
    "title": "Title test",
    "msg": "Text of the test",
    "code": 2,
  },
  "delay_while_idle" : false,
  "priority" : "high",
  "content_available" : true
}
</code></pre>

<p>What I can say is that when and every time I send a message while the application is in background, I get the following display in logcat</p>

<pre><code>07-22 12:54:21.400 14316-14316/? W/GCM-DMM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=com.google.firebase.quickstart.fcm (has extras) }
</code></pre>

<p>So the message is well received by the device but not transferred to onMessageReceive().</p>

<p>I saw many posts about such problem but the answers are always vague as what we can say is that it work for some and don't work for some others.
So I'd like to know if someone recently found a more precise explanation to this problem because I wonder if it couldn't come from the development environment as I tried to build older working project with the newly updated studio, sdk, build tools and I face the same problem, GCM/FCM messages are not received anymore by the newly built application.</p>

<p><strong>EDIT</strong></p>

<p>After more investigations, I saw in logcat that my application is force closed when I swipe it out from the recent apps list. This certainly explain it cannot be able to handle the message received by the device.</p>

<pre><code>07-23 23:12:29.002 671-31254/? I/ActivityManager: Killing 17453:com.google.firebase.quickstart.fcm/u0a297 (adj 9): remove task
07-23 23:12:29.016 14316-14524/? D/GCM: Removing messenger 0:com.google.firebase.quickstart.fcm
07-23 23:12:29.017 671-2998/? I/WindowState: WIN DEATH: Window{2a27cf7 u0 com.google.firebase.quickstart.fcm/com.google.firebase.quickstart.fcm.MainActivity}
07-23 23:12:30.148 671-4851/? I/ActivityManager: Force stopping com.google.firebase.quickstart.fcm appid=10297 user=0: from pid 18289
</code></pre>

<p>I also tried a working project of mine built few weeks ago, based on GCM 8.4.0, sdk 23, java 1.7, which was working and I get the same problem; Application is force closed.</p>

<p>This is observed on 2 different devices I successfully used to test my working project: nexus 7 LTE 6.0.1 and GT-9295 5.0.1<br>
The only difference I see now is the version of Android Studio/gradle. Working project were built with 1.5.2 and now I use 2.1.2, I cannot build any working application anymore.<br>
I get this problem on 2 different computers and on one of them I reinstalled everything!</p>