Android Question java.lang.NullPointerException: null receiver

peacemaker

Expert
Licensed User
Longtime User
What this error mean ?

Line 192 is the latest line "End Sub" of
Private Sub JobDone (Job As HttpJob) in the class that downloads by OKHttputils2 built-in lib v.2.20 (not a class). B4A v.6.

Job is successful, but error in the end of the sub. And error only in DEBUG mode at first start, if to restart "running previous successful shell app" - NO ERROR ! Release looks OK, but sometimes the black screen and app is closed.
Job result is
B4X:
StartActivity(Client)
CallSub2(Client, "Refresh_tab", m)

where m is Map, Client is the activity to be started.

B4X:
** Service (httputils2service) Start **
job_received=GetToken
Received Token for Session = 45f5304463dada979933ca3506d80f79033839cf
Error occurred on line: 192 (clsBallovnet)
java.lang.NullPointerException: null receiver
    at java.lang.reflect.Field.get(Native Method)
    at java.lang.reflect.Field.get(Field.java:279)
    at anywheresoftware.b4a.shell.Shell.getStateAfterUserSubHelper(Shell.java:513)
    at anywheresoftware.b4a.shell.Shell.getStateAfterUserSub(Shell.java:496)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:403)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at anywheresoftware.b4a.BA$2.run(BA.java:328)
    at android.os.Handler.handleCallback(Handler.java:815)
    at android.os.Handler.dispatchMessage(Handler.java:104)
    at android.os.Looper.loop(Looper.java:194)
    at android.app.ActivityThread.main(ActivityThread.java:5552)
    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:964)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)
** Activity (main) Pause, UserClosed = true **
 
Last edited:

peacemaker

Expert
Licensed User
Longtime User
"Client" activity is null, if to break point. But activity is on the screen ! How can it be null ?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Have you tried to use CallSubDelayed?
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
I thought i tried...
But did now - and works OK ! THanks !
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Now
B4X:
java.lang.NullPointerException: expected receiver of type activty.client, but got null
at the same place.
But the activity CLIENT was started before, after first login Http job. And Activity_Resume sub of this CLIENT activity - has started this second HTTP job with error.
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Erel, yes - i have tried, the same error "null receiver" under Android5, or "
expected receiver of type %packagename%.client, but got null" under Android 4.2
:

B4X:
LogCat connected to: YSEIFMEM99999999
--------- beginning of system
--------- beginning of main
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
No partial wakelock.
** Service (httputils2service) Create **
** Service (httputils2service) Start **
Received Token for Session = 2bb2c71c14465a318c75d09d6cd0551960b3ec3a
Error occurred on line: 188 (clsBallovnet)
java.lang.NullPointerException: null receiver
    at java.lang.reflect.Field.get(Native Method)
    at java.lang.reflect.Field.get(Field.java:279)
    at anywheresoftware.b4a.shell.Shell.getStateAfterUserSubHelper(Shell.java:513)
    at anywheresoftware.b4a.shell.Shell.getStateAfterUserSub(Shell.java:496)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:403)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:247)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
    at anywheresoftware.b4a.BA$2.run(BA.java:328)
    at android.os.Handler.handleCallback(Handler.java:815)
    at android.os.Handler.dispatchMessage(Handler.java:104)
    at android.os.Looper.loop(Looper.java:194)
    at android.app.ActivityThread.main(ActivityThread.java:5552)
    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:964)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:759)
** Activity (main) Pause, UserClosed = true **

The line number is "End Sub".
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
In release-mode all looks OK, but the customer reports that sometimes after start - just black screen (Job is failed, data is not received\parsed), the same in the debug mode at this error.
Erel, emailed the project to [email protected]
 
Last edited:
Upvote 0
Top