I have my app crashes, on GCM listener onMessageReceived. I figured this out from Fabric-Crashlytics. I don't know what the app received. Following is the Exception from Crashlytics.
Fatal Exception: java.lang.NullPointerException at com.mjhram.ttaxidriver.gcm_client.MyGcmListenerService.onMessageReceived(MyGcmListenerService.java:51)
at com.google.android.gms.gcm.GcmListenerService.zzt(Unknown Source)
at com.google.android.gms.gcm.GcmListenerService.zzk(Unknown Source)
at com.google.android.gms.gcm.GcmListenerService.zza(Unknown Source)
at com.google.android.gms.gcm.GcmListenerService$1.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at java.lang.Thread.run(Thread.java:856)
This issue was identified by some peoples as it is caused by TMMARS (Trend Micro MARS) Service:
- DownloadManager IllegalStateException creating a download in DIRECTORY_DOWNLOADS
- https://github.com/google/gcm/issues/176
Both references the problem, the cause, but without details, or how they solved the issue. Following is onMessageReceived:
public void onMessageReceived(String from, Bundle data) {
String message = data.getString("message");
Log.d(TAG, "From: " + from);
Log.d(TAG, "Message: " + message);
if (from.startsWith("/topics/")) {//crah here
// message received from some topic.
} else {
sendNotification(message);
}
}
The exception is raised on line [if (from.startsWith("/topics/"))]. I am not sure if "from" is passed as null here!
Anyone can help me figure out what is happening? and what is my apk receives?
Note: This happens on Rooted device.
UPDATE#1: Receiver in Android Manifest
<receiver
android:name="com.google.android.gms.gcm.GcmReceiver"
android:exported="true"
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.mjhram.ttaxidriver" />
</intent-filter>
</receiver>