Hey Guys,
I have been working on an app for several weeks and did never get the live view to crash. But since some days the app crashed regularly. Sometimes right after start and everytime when loading one special screen.
I have checked all blocks but can not find a problem. What bothers me: the crash on the startscreen does not happen everytime and when I download the app on my android, it does NOT crash at all…
Any ideas where to look? (Can’t share the code as I use lots of api requests with keys)
Any help is welcome!
Look for somewhere where you’re feeding a block something it can’t handle. Getting object properties of a non-object, getting item 4 of a two item list, inserting a list item into a variable that doesn’t have a list, setting something to a variable that isn’t defined, etc.
If you have a consistent crash on one screen, I’d start unplugging blocks until it stops crashing. Then look at what you unplugged most recently.
Always check if the stored variable is null before performing any operation on it.
Thunkable cannot correctly add a list to any variable that is null. If you are trying to add a list to app variable or stored variable then check if null first and assign it Empty List block first.
Hi Muneer,
I have a “followup question”:
When you told me about the problems thunkable has with null I changed the initialization of my variables to an empty string (the red textblock).
I just found a bug in my code where it always crashed:
I assignet an “app variable” with an empty string to the “open link” block. When this block get call it crashes. So iam curious: do I need to check EVERY variable bevor using it? If so, what do I need to check? null, empty string, anything else?
Well, it’s probably not going to be a good user experience if your user presses the button and nothing happens because the variable isn’t set, either. It makes sense to either prevent lack of data (i.e. by setting defaults that cause sensible behavior in the app) or to give a human-readable error message (“please enter your email before continuing”). When you check variables, you’ve got an opportunity to provide a user-friendly response from the app, not just to prevent it from crashing.
Well it depends:
Let’s say you have a form. You ask for several inputs which you save in an object or separate variables. Some are optional. If the user leaves the input blank, you store “null” or an empty string. If this leads to problems down the road in thunkable, it is a problem.