parse4cn1 Push errors when background

26 views
Skip to first unread message

Mario Barón

unread,
Jan 5, 2018, 11:00:38 AM1/5/18
to CodenameOne Discussions
Hi guys,

I'm getting a rather weird error when receiving push notifications through Parse using the parse4cn1 library: 

01-05 10:28:20.143 2539-2539/? W/GCM-DMM: broadcast intent callback: result=CANCELLED forIntent { act=com.google.android.c2dm.intent.RECEIVE flg=0x10000000 pkg=com.guarumo.ego (has extras) }
01-05 10:28:20.176 20803-20803/? D/AndroidRuntime: Shutting down VM
01-05 10:28:20.186 20803-20803/? E/AndroidRuntime: FATAL EXCEPTION: main
                                                   Process: com.guarumo.ego, PID: 20803
                                                   java.lang.RuntimeException: Unable to start receiver com.parse.CN1ParsePushBroadcastReceiver: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.InputStream com.codename1.impl.CodenameOneImplementation.getResourceAsStream(java.lang.Class, java.lang.String)' on a null object reference
                                                       at android.app.ActivityThread.handleReceiver(ActivityThread.java:2646)
                                                       at android.app.ActivityThread.access$1700(ActivityThread.java:155)
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394)
                                                       at android.os.Handler.dispatchMessage(Handler.java:102)
                                                       at android.os.Looper.loop(Looper.java:135)
                                                       at android.app.ActivityThread.main(ActivityThread.java:5343)
                                                       at java.lang.reflect.Method.invoke(Native Method)
                                                       at java.lang.reflect.Method.invoke(Method.java:372)
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
                                                    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.InputStream com.codename1.impl.CodenameOneImplementation.getResourceAsStream(java.lang.Class, java.lang.String)' on a null object reference
                                                       at com.codename1.ui.Display.getResourceAsStream(Display.java:2615)
                                                       at com.codename1.io.Log.print(Log.java:331)
                                                       at com.codename1.io.Log.p(Log.java:284)
                                                       at com.parse4cn1.util.Logger.debug(Logger.java:89)
                                                       at com.parse.CN1ParsePushBroadcastReceiver.writeLog(CN1ParsePushBroadcastReceiver.java:185)
                                                       at com.parse.CN1ParsePushBroadcastReceiver.writeDebugLog(CN1ParsePushBroadcastReceiver.java:198)
                                                       at com.parse.CN1ParsePushBroadcastReceiver.onPushReceive(CN1ParsePushBroadcastReceiver.java:58)
                                                       at com.parse.ParsePushBroadcastReceiver.onReceive(ParsePushBroadcastReceiver.java:117)
                                                       at android.app.ActivityThread.handleReceiver(ActivityThread.java:2639)
                                                       at android.app.ActivityThread.access$1700(ActivityThread.java:155) 
                                                       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1394) 
                                                       at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                       at android.os.Looper.loop(Looper.java:135) 
                                                       at android.app.ActivityThread.main(ActivityThread.java:5343) 
                                                       at java.lang.reflect.Method.invoke(Native Method) 
                                                       at java.lang.reflect.Method.invoke(Method.java:372) 
                                                       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905) 
                                                       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700) 

When the push is sent and the app is in the foreground, the app does what it's supposed to. I've gone through sidiabale's documentation and test app over and over but continue getting the same error. I'm not sure if this may be caused by initializing Parse in a place where it shouldn't be initialize. PS: I'm initializing Parse in the "public void init(Object context)" method in the main class for my project right after registering my custom classes to store on local storage. The project is a new GUI Builder project so I don't have a Statemachine.

Thanks in advance, I really appreciate your help.

Mario Barón

unread,
Jan 5, 2018, 11:16:13 AM1/5/18
to CodenameOne Discussions
Sorry guys, 

I forgot to mention this is only happenning in the Android version of the app, iOS is working normally.

Shai Almog

unread,
Jan 6, 2018, 12:57:00 AM1/6/18
to CodenameOne Discussions
Hi,
the Parse4cn1 Logger is invoked when the app is suspended and Display calls might fail. In background tasks you can't invoke most of the Display calls.
Reply all
Reply to author
Forward
0 new messages