Android Question It works in debug mode, not in Release mode.

ykucuk

Well-Known Member
Licensed User
Longtime User
I have a panel (b4xview) that functions correctly in debug mode but not in release mode; it's a simple click panel with no special libraries involved. Can anyone suggest why this might be happening and how to resolve the issue?

B4X:
Sub CasePanel_Click
  MyApp.Initialize
   Dim bt As B4XView =Sender
   Log(bt.Tag)
  Wait For ( MyApp.GetCaseDetail("&CaseID="& bt.Tag &"&")) Complete (CaseDetail As Map)

Error

b4xmainpage$ResumableSub_CasePanel_Clickresume (java line: 984)
java.lang.RuntimeException: Object should first be initialized (B4XView).
 

Attachments

  • Screenshot 2024-05-08 at 6.40.13 PM.png
    Screenshot 2024-05-08 at 6.40.13 PM.png
    233 KB · Views: 102

jahswant

Well-Known Member
Licensed User
Longtime User
B4X:
Sub CasePanel_Click
 Dim bt As B4XView =Sender 'Always first here.
  MyApp.Initialize
  
   Log(bt.Tag)
  Wait For ( MyApp.GetCaseDetail("&CaseID="& bt.Tag &"&")) Complete (CaseDetail As Map)
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
It is simple. In fast working Release mode your Sender is not initialized on time.
Why ? It is a second question.
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
I had an intermittent issue like this in a project. I ended up adding an "Initialization_Complete" event to my class that it raises once it's done with startup and I wait for that after initializing it before continuing.
 
Upvote 0

ykucuk

Well-Known Member
Licensed User
Longtime User
I had an intermittent issue like this in a project. I ended up adding an "Initialization_Complete" event to my class that it raises once it's done with startup and I wait for that after initializing it before continuing.
Can you help me about Initialization_Complete . it can solve my issue
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
Without seeing your code I cannot really speak to your exact issue or methodology.

In my case, I pass the instantiating activity to the class and then call back to it when finished. The activity code basically looks like:
B4X:
...
MyClass.initialize(Me)
Wait for (MyClass.Startup(Parm1, Parm2)) Initialization_Complete (Success as Boolean)
... ' more code
Wait For (MyClass.NextFunction(Parm1, Parm2)) Complete (Result as boolean)
..... ' and so on

The MyClass class saves the passed-in activity to a "myCaller" variable and uses it to callsub back as necessary, for example
B4X:
... 'doing some initial stuff, now all done
CallsubDelayed(myCaller, "Initialization_Complete", True)
 
Upvote 0
Top