Android Question callsub between classes bugs only in release mode

sorex

Expert
Licensed User
Longtime User
Hello,

I have a weird issue here.

I have a main module and 2 different classes.

When I want to do call subs in a way like

class 1 > class 2 > class 1 based on mainmodule class 1 reference

then it's working perfect in debug mode.

when using release it always returns a null pointer exeption.

I isolated the problem and attached it as a project.

If anyone can have a look at this problem and enlighten me about the cause then please do so.
 

Attachments

  • callsub_bug.zip
    1.8 KB · Views: 137
Last edited:

sorex

Expert
Licensed User
Longtime User
bizarre, now it's not working in debug mode either anymore :confused:

Edit: now it worked again and the output should be

B4X:
** Activity (main) Create, isFirst = true **
call testsub
test sub reached
end sub reached
** Activity (main) Resume **


not

B4X:
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = true **
call testsub
test sub reached
class2_testsub (java line: 48)
java.lang.NullPointerException
    at b4a.example.class2._testsub(class2.java:48)
    at b4a.example.class1._start(class1.java:57)
    at b4a.example.main._activity_create(main.java:321)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
    at b4a.example.main.afterFirstLayout(main.java:100)
    at b4a.example.main.access$100(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:78)
    at android.os.Handler.handleCallback(Handler.java:587)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3683)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    at dalvik.system.NativeStart.main(Native Method)
java.lang.NullPointerException
 
Last edited:
Upvote 0

sorex

Expert
Licensed User
Longtime User
Thanks Erel, that solved it in the isolated example.

In the real project it then give...

Error description: Cannot access activity object from sub Process_Globals.
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
and that error occurs on the line where the object is define

B4X:
Sub Process_Globals
Dim c1 As class_name
End Sub
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
I see, so I guess I need to use my old workaround then which is an extra sub in the main module that callsubs the right sub in the class?
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
ok, it works now with the old method.

I hoped there would've been a direct way without the need to have a bunch of sub call subs in the main activity.
 
Upvote 0
Top