Android Question (Solved)Recieving "java.lang.RuntimeException: Array not expected..."

opus

Active Member
Licensed User
Longtime User
Hi I'm recieving a "java.lang.RuntimeException: Array not expected..." in this line:
B4X:
 If (MyList.Size=0 AND MyBoolean=False) Then
MyList is a (initialised) List of custom class objects
MyBoolean is a Boolean
This particular line is run a lot with no problem before the error occurs. Logging both variables (MyList.Size and MyBoolean) rigth before that line doesn't show any problem. However the problem is raised again.
Where could I look elsewhere?
 

fixit30

Active Member
Licensed User
Longtime User
You should try not using brackets.

B4X:
If MyList.Size = 0 AND MyBoolean = False Then
 
Upvote 0

opus

Active Member
Licensed User
Longtime User
Thanks forv the reply, however IMHO if that would be the reason an exception should have been raised before.

I did some more tests.
That line is within a Do..Loop which holds an DoEvents command. I figured that DoEvents neccessary because the line inside the If-statement starts a timer, which should do something.
By changing the setup from using a Do..Loop with DoEvents to a second Timer, the error isn't showing.
But WHY??????, I'm curious!
 
Upvote 0

opus

Active Member
Licensed User
Longtime User
The code that causes the Problem:
B4X:
Do Until MyBooleanB=True
  If (MyList.Size=0 And MyBooleanA=False) Then 'the above posted exception is raised here!
     
       StartTimer 'This Sub fills MyList with items and starts a timer,
                        'after several runs of its _Tick-Routine the MyList gets its items removed and MyBooleanA is set to False
                      
  End If
  If CheckSomething=True Then
     MyBooleanB=True
   End If
Loop
since the exception isn't raised during the first Iteration nor at the same Iteration during several test-runs using the same Setup, I believe it could be a Problem caused by a race-condition between the Do..Loop and the Timer.
 
Upvote 0

opus

Active Member
Licensed User
Longtime User
Tanks for the reply Erel. Yes I already figured that using Timers solely would work.
Is there an explanation why it does not in a loop? I'm just curious.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I don't know why you got this specific error message. For this I need to go over all the code. However almost all events, including the timer events will not fire while the main thread is busy. They will only fire when the main thread is free to process the message queue.

Android will kill the process if the main thread is not processing the message queue for more than 5 - 10 seconds.
 
Upvote 0
Top