List error during development but not at run time

i get a list error saying attempt to get list value from item of length 0. this error does not happen in the compiled app on the phone only during the development phase. there is no indication in which block it happens and i tried to disable all relevant blocks and cannot pin it down.
any suggestions? that prevents me to perform decent development because the error pops up every 5 sec

thanks in advance


Find all select list item blocks. It would be better if you would post a screenshot of your blocks.

and as the error keeps popping up, check those items being run by a clock timer


Export your .aia file and upload it here.

For lack of source, I would bet on the Companion's TinyDB garbage can is clogging your app with initial values left over from other app testing.

erhards_apps_v185.aia (3.5 MB)

here it is. it is the screen MOTIONTRACK

thanks for your time



How do you know arrSizeMax is within the length of list arrspeed?

If you want the last item of arrspeed, use index(length of list(arrspeed))

Better yet, check if length of list(arrspeed) > 0 before starting any type of work on it.

thanks for your feedback

i thought i take care of this in the screen initialize block where i fill the empty list with '0'.
should this not take care of it?
also i did not get this error before so i thought i made some changes that would explain it but cannot find a problem.
and also this error does not seem to affect the runtime behavior



What is the initial value of arrSizeMax?

Is it perhaps 0 ?

no it is 15 - i set it during variable initialization

Provide a test aia that is as simple as possible that shows the problem (and not one that contains many screens and is almost 4 MB in size).

1 Like

sorry i will try to do better but it takes me quite a bit of time to condense the code down this much.
btw what is the best method to use only one screen - there is no screen extract function so i assume just deleting all the excess screen is the way to do it.
there is no trick how the debugger can point me to a block where the message comes from?
also when i disable a block is that going into effect right away or do i need to reset connection and reconnect to the phone?
sorry lot's of questions you probably answered already millions of times.
what i am trying first is compare to an older version where this problem did not show up


Yes, but it takes us a lot of time to work through your app/code.
And we look at a lot of apps/problems daily ... :wink:

See here.



Does this section of code make sense to you?

It does nothing but replace the items of arrspeed with themselves!

ok i figured it out.
i understand that you guys doing a tedious job but if appinventor had a better debug environment it would help us all a lot

so here is what happens

in the motiontrack.initialize
the list was never generated because it was after the
file1.scope and
file.append statement

so the add.items to list loop was never executed because the program jumped out of the block and then the list was length 0 - makes sense.
once i move the add.item loop to the top (just BEFORE the file stuff) all worked.'
also because of the file1.scope block
i get in the development environment the run time error
'item is neither class nor type'
but this shows up only once and all is ok

to ABG's question
you are right that is a questionable code and i took it out.
the purpose was that i tried to preserve the data in case the INITIALIZE is done again when i leave the app and come back but that does not work either i guess, so you are right - was a bad idea.

all this file stuff in android 11 is still a black box to me but at least now i can continue in the development environment with out the pop up error.

we need better debugging and break points.

so thanks again and i am really sorry you had to crawl through my code - not nice i know.
i am not sure how i can support your work, where do i donate?

but i hope my 2 hour debug activity and explanation also helps you a little :slight_smile:

thanks again

Thanks for taking the time to explain how the error happened.

We remember error patterns and they help us when other users have them.

The AI2 home page has a donate button.

I see you have some extensions.
Don't forget your extension author too.

1 Like

Double check your Companion version against AI2's current version.

Also, I spotted these:

Opening a Screen that is already open can fill RAM.
Try to close screens as often as you open them.

Unless this broke during my blocks editor sifting, tis could cause trouble.

1 Like

ABG thanks for the hints will fix them- appreciate it.
i have not forgotten the extension people - served them already :slight_smile:

ABG, i updated the companion and now the error
'item is neither class nor type'
is gone
thanks for the suggestion - i forgot about this because i did turn automatic update off


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.