Error: Application has stopped

After installing my app on phone, everytime I use it for a while appears the error "Application has stopped". What can I do to stop the app creating new screens until memory is over (I guess this is the problem)?

Thank you!

Welcome @Higor_Martinez

You have to tell something more about your app. Does your app has many screens or large assets?

Hi @Higor_Martinez Welcome to Community
Show your Screen1 initialize blocks.

The app has 8 screens, all screens just with text and images (using like 1 image per page), so I'm not using large assets. The page with the most resources is a page that fires questions according to the answer until it reaches the test final result according to the previous answers (total of 7 questions).

Even 1 image can be a problem. Can you tell how big your images are in pixelsize? And can you show how you switch screens?

All the images is 600x600 pixels. The elements on page 1 redirect you to the test page or to the page with more information on the theme of my application. The test page shows the next questions according to the answers given, manipulating the box height value for each question.

The home page redirects you to a test page or more informations page.

You are getting memory problems because you are only opening screens but not closing them. Read this on how you can do that.

https://puravidaapps.com/tribblehunter.php

You are not switching screens correctly.
Use this method to switch screens:

Yes, I thought this was the problem, but I had no idea how to "close screens". Thank you for your help, I'll try Tribblehunter's multiple screen method :slight_smile:

1 Like

Hello Higor

An alternative would be to use Virtual Screens. However, you have not explained what your App does, why it needs 8 Screens - it might not need that many, it could just be the way you are creating it. Are any of the 8 Screens similar to each other, except for content such as text and images?

Higor, your images are potentially large in terms of bytes, that can certainly take up a lot of memory. Have you optimised them for Android? See my site:
https://www.professorcad.co.uk/appinventortips#TipsImages

1 Like

Hi, Chris. The screens are not similar, so I really need to use 8, but I'm trying to reduce. Do you have any tutorial about Virtual Screens? Thank you for your help!

Hi Higor

When we define virtual screens, we use one 'real' App Inventor Screen (most often Screen1). Screen-sized Vertical Arrangements on it are displayed/hidden as required - they are the Virtual Screens. This is generally a better approach for multi-screen Apps, they share data without having to "pass" it between screens and it also reduces code duplication, making the App more efficient and the code easier to follow if you have to return to it at a later date. They eradicate Screen switching problems, a major bonus.

So, instead of seperate houses, virtual screens are rooms of the same house.

1 Like

Indeed! Actually I did that without knowing I was creating "Virtual Screen". In the beginning the app had 16 screens, using one screen per question of the test I'm creating, after I reduced to 8 screens and all the questions just in one page using vertical arrangements (one per question). So I'll now read your tips and try to reduce more the number of screens. Thank you!

HOWTO: Yet Another Tabbed Screens Demo