# Debugging Crashes in live view

**URL:** https://community.thunkable.com/t/debugging-crashes-in-live-view/1253058
**Category:** Questions about Thunkable X
**Created:** [April 29, 2021, 2:08pm UTC](https://community.thunkable.com/t/debugging-crashes-in-live-view/1253058 "2021-04-29T14:08:55Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![tmurachpx](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@tmurachpx](https://community.thunkable.com/u/tmurachpx)
#### Post date: [April 29, 2021, 2:08pm UTC](https://community.thunkable.com/t/debugging-crashes-in-live-view/1253058/1 "2021-04-29T14:08:55Z")

</div>

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!

---

<div class="post-metadata">

### Author: ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)
#### Post date: [April 29, 2021, 2:11pm UTC](https://community.thunkable.com/t/debugging-crashes-in-live-view/1253058/2 "2021-04-29T14:11:18Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [April 29, 2021, 2:12pm UTC](https://community.thunkable.com/t/debugging-crashes-in-live-view/1253058/3 "2021-04-29T14:12:07Z")

</div>

The first thing comes to mind is **stored variables**. Are they used in your app and how are you handling them?

The other thing is the famous API and next is computations that would lead unexpected results.

---

<div class="post-metadata">

### Author: ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)
#### Post date: [April 29, 2021, 2:14pm UTC](https://community.thunkable.com/t/debugging-crashes-in-live-view/1253058/4 "2021-04-29T14:14:47Z")

</div>

Ah, the API. The perpetual enemy and bane of any Thunker. That’s a very likely possibility.

---

<div class="post-metadata">

### Author: ![tmurachpx](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@tmurachpx](https://community.thunkable.com/u/tmurachpx)
#### Post date: [April 29, 2021, 2:14pm UTC](https://community.thunkable.com/t/debugging-crashes-in-live-view/1253058/5 "2021-04-29T14:14:59Z")

</div>

I make heavy use of them. What thinks should I look out for?

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [April 29, 2021, 2:21pm UTC](https://community.thunkable.com/t/debugging-crashes-in-live-view/1253058/6 "2021-04-29T14:21:09Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![tmurachpx](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@tmurachpx](https://community.thunkable.com/u/tmurachpx)
#### Post date: [April 29, 2021, 2:27pm UTC](https://community.thunkable.com/t/debugging-crashes-in-live-view/1253058/7 "2021-04-29T14:27:20Z")

</div>

Thanks for the advice! When initializing a stored variable, would you recommend to assign it an empty text/list/object instead of null?

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [April 29, 2021, 2:34pm UTC](https://community.thunkable.com/t/debugging-crashes-in-live-view/1253058/8 "2021-04-29T14:34:33Z")

</div>

Yes,  
Thunkable does not know what to do when it encounters `null`. This is the reason you get the crash.

So unless you do not deliberately want a `null`, you should avoid it in the code.

---

<div class="post-metadata">

### Author: ![codeswept](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/codeswept/32/87755_2.png) [@codeswept](https://community.thunkable.com/u/codeswept)
#### Post date: [April 29, 2021, 2:37pm UTC](https://community.thunkable.com/t/debugging-crashes-in-live-view/1253058/9 "2021-04-29T14:37:43Z")

</div>

Do this:

> [@codeswept](#):
>
> When the screen opens  
> If stored variable myVariable is null  
> Set stored variable myVariable to empty list/text block/0/whatever you want

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [April 29, 2021, 2:55pm UTC](https://community.thunkable.com/t/debugging-crashes-in-live-view/1253058/10 "2021-04-29T14:55:26Z")

</div>

You can try my method of debugging:

> [@Debugging in Thunkable X (Video)](https://community.thunkable.com/t/debugging-in-thunkable-x-video/849471):
>
> I thought I’d share a process I use for debugging my projects. It involves creating a function that can be used over and over throughout the code blocks in order to help determine where things are going wrong, whether or not certain blocks are ever triggering, and what the values of several variables are. Here’s a screenshot of what I’ve set up: The real power comes from being able to quickly change the delay (and even set it to 0 seconds) or just remo…

---

<div class="post-metadata">

### Author: ![tmurachpx](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@tmurachpx](https://community.thunkable.com/u/tmurachpx)
#### Post date: [May 4, 2021, 8:22am UTC](https://community.thunkable.com/t/debugging-crashes-in-live-view/1253058/11 "2021-05-04T08:22:04Z")

</div>

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?

thanks in advance 😉  
greetings Torben

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [May 4, 2021, 11:10am UTC](https://community.thunkable.com/t/debugging-crashes-in-live-view/1253058/12 "2021-05-04T11:10:11Z")

</div>

Not for everything.

- The object blocks like `get property` will crash if the object is null.
- The API response will crash the system if you try to use anything in it and it happens to be null.
- Using the `stored variable` while null.

Now your telling me using the `open link` block crashes the system.

But certainly not for everything.

---

<div class="post-metadata">

### Author: ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)
#### Post date: [May 4, 2021, 12:44pm UTC](https://community.thunkable.com/t/debugging-crashes-in-live-view/1253058/13 "2021-05-04T12:44:24Z")

</div>

> [@tmurachpx](#):
>
> So iam curious: do I need to check EVERY variable bevor using it?

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.

---

<div class="post-metadata">

### Author: ![tmurachpx](https://avatars.discourse-cdn.com/v4/letter/t/c68b51/32.png) [@tmurachpx](https://community.thunkable.com/u/tmurachpx)
#### Post date: [May 4, 2021, 2:01pm UTC](https://community.thunkable.com/t/debugging-crashes-in-live-view/1253058/14 "2021-05-04T14:01:49Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [November 8, 2024, 1:22pm UTC](https://community.thunkable.com/t/debugging-crashes-in-live-view/1253058/15 "2024-11-08T13:22:52Z")

</div>


