App crashes before opening!

69 views
Skip to first unread message
Assigned to ewpa...@gmail.com by taifu...@gmail.com

BierGarten100

unread,
Dec 18, 2019, 7:17:34 AM12/18/19
to mitappinv...@googlegroups.com
First, sorry about my english. ^^

Hello,
i have a big problem with my AppInventor App.
When i build my app and try open the .apk on my phone,
the app is crashing. I dont know why?

I use >> 1x NFC, 1x Clock, 1x TinyDB, 1x Notifier and
I use 1 Extension by Taifun. Its called "com.puravidaapps.TaifunTM6.aix" for calling my IMEI.

My Block for "Screen1.Initialize" show like this:
blocks.png







Can any one tell me why my app is crashing or how can i localize bugs / errors?

Chris Ward

unread,
Dec 18, 2019, 7:24:42 AM12/18/19
to MIT App Inventor Forum
Hi

Did you make your own App Icon? If so, it should be 96 x 96 pixels, zero compression PNG.

https://www.professorcad.co.uk/appinventortips#TipsApk              Cannot Build/Install/Run APK


BierGarten100

unread,
Dec 18, 2019, 7:29:21 AM12/18/19
to MIT App Inventor Forum
Yes i create a own App Icon as .png and the size is 360x360 and not background (transparent).
But I thought it will automatically scale down?

Chris Ward

unread,
Dec 18, 2019, 7:35:36 AM12/18/19
to MIT App Inventor Forum
Actually, there is a lot wrong with the start of your App!

PhoneState.png


Above is effectively your Blocks, but arranged correctly. However, I am not familiar with the "Phone State" permission - and storing the state in TinyDb? Is the state guaranteed never to change?



Chris Ward

unread,
Dec 18, 2019, 7:37:11 AM12/18/19
to MIT App Inventor Forum
... you thought wrong :) 

Chris Ward

unread,
Dec 18, 2019, 7:38:21 AM12/18/19
to MIT App Inventor Forum
What does the Procedure "Starten" actually do? That too might be doing something that causes a crash.

BierGarten100

unread,
Dec 18, 2019, 7:51:02 AM12/18/19
to MIT App Inventor Forum
 I have try to scale down the icon to max 96x96 but doesnt work. Crashing!

Actually, there is a lot wrong with the start of your App!
Ok i try your method. But i think is the same. 

Above is effectively your Blocks, but arranged correctly. However, I am not familiar with the "Phone State" permission - and storing the state in TinyDb? Is the state guaranteed never to change?
- "Phone State" permission = You can call the IMEI or Phonenumber or SIM ID what ever.
- No, there is no guarantee that something will change.
  But whoever allows it for the function of the app will surely not switch it off somewhere in the    settings? If it does, the app will not work as it should. :D

EDIT: Your Method with the Initialize dont work for me.

BierGarten100

unread,
Dec 18, 2019, 7:54:59 AM12/18/19
to MIT App Inventor Forum
What does the Procedure "Starten" actually do? That too might be doing something that causes a crash.

It set the Language Text.
When the Phone Localize in England then set it to English Text and when in Germany in German. And test the app first start with TinyDB entry "FirstStart". When empty then register when not empty login.

Chris Ward

unread,
Dec 18, 2019, 8:17:12 AM12/18/19
to MIT App Inventor Forum
Ok i try your method. But i think is the same. 

It is not the same. I would not waste my time offering you something your code already performs correctly.

So when you say "it doesn't work", how do you measure that? Simply that the App still crashes even with a new icon (exactly as I specified, or just remove your icon for now and App Inventor will use a default AI icon) and a safe Screen Initialisation?

Can we see the Starten Procedure?

 

Chris Ward

unread,
Dec 18, 2019, 8:24:47 AM12/18/19
to MIT App Inventor Forum
Calling READ_PHONE_STATE my require prior knowledge of the phone's Android Version (API Level). Taifun has an extension that can verify the API Level.

Did your App work via the Companion?

BierGarten100

unread,
Dec 18, 2019, 8:31:35 AM12/18/19
to MIT App Inventor Forum
It is not the same. I would not waste my time offering you something your code already performs correctly.
 Ok my fault... sorry. :/

So when you say "it doesn't work", how do you measure that? Simply that the App still crashes even with a new icon (exactly as I specified, or just remove your icon for now and App Inventor will use a default AI icon) and a safe Screen Initialisation?
I meen with "it diesn't work", with change of the icon and without a icon (default AI icon).

 Can we see the Starten Procedure?

blocks (1).png

 Its the simple "German" version. This doesnt work too.

Chris Ward

unread,
Dec 18, 2019, 8:33:25 AM12/18/19
to MIT App Inventor Forum
Yet another question - did someone here advise you to ask for READ_PHONE_STATE permission?


If your app targets Android 9 (API level 28) or lower, the method returns null or placeholder data if the app has the READ_PHONE_STATE permission. Otherwise, a SecurityException occurs.

BierGarten100

unread,
Dec 18, 2019, 8:41:42 AM12/18/19
to MIT App Inventor Forum
Did your App work via the Companion?
I dont know what you meen with "Companion". :x

 Yet another question - did someone here advise you to ask for READ_PHONE_STATE permission?
Yes. Taifun have in his wiki (https://puravidaapps.com/telephonymanager.php)
the (NOTE: This block needs the permission READ_PHONE_STATE. See the example project #1 below about how to ask for this permission.)
And all from this "wiki" i have try. 


If your app targets Android 9 (API level 28) or lower, the method returns null or placeholder data if the app has the READ_PHONE_STATE permission. Otherwise, a SecurityException occurs.
 Does that mean it just doesn't work anymore?

Chris Ward

unread,
Dec 18, 2019, 8:44:08 AM12/18/19
to MIT App Inventor Forum
.. I think a better question would be - why are you asking for that specific permission?

Also, see my tips here:

Give every component a meaningful name - but always retain the component type name e.g. Label_PickedValue_Scrn01, Button_CalcTotal_Scrn01

This method makes it easier for others to understand your code.

At this point, we are interested in pin-pointing the cause of the crash, so lets remove one suspect at a time to see what happens:

1) Remove the permission request. Build the APK. What is the result?
2) Remove the Procedure "Starten" (you can store it in the BackPack). Build the APK. What is the result?


BierGarten100

unread,
Dec 18, 2019, 9:14:19 AM12/18/19
to MIT App Inventor Forum
1) Remove the permission request. Build the APK. What is the result?
App crashing.

2) Remove the Procedure "Starten" (you can store it in the BackPack). Build the APK. What is the result?
App crashing too. 

Chris Ward

unread,
Dec 18, 2019, 9:16:17 AM12/18/19
to MIT App Inventor Forum
.... Did you remove the call to "Starten" too?

BierGarten100

unread,
Dec 18, 2019, 9:17:36 AM12/18/19
to MIT App Inventor Forum
.... Did you remove the call to "Starten" too?
Yes. 

BierGarten100

unread,
Dec 18, 2019, 9:23:52 AM12/18/19
to MIT App Inventor Forum
When i Disable a Block and Build the APK.
Ignores the APK this Block? I will try step by step to Enabled the blocks.

Chris Ward

unread,
Dec 18, 2019, 9:26:47 AM12/18/19
to MIT App Inventor Forum
The App Inventor Companion is used to test the App code as you define the code. It's one way to ensure that each section of the code works, before continuing to develop the next.

BierGarten100

unread,
Dec 18, 2019, 9:30:40 AM12/18/19
to MIT App Inventor Forum
The App Inventor Companion is used to test the App code as you define the code. It's one way to ensure that each section of the code works, before continuing to develop the next.
Oh... i am so stupid. ^^
Yes the Companion... There can i start the App but it doesn't load my label text after start.

The app is complet destroyed. But why and how? :/ 

Chris Ward

unread,
Dec 18, 2019, 9:30:59 AM12/18/19
to MIT App Inventor Forum
Re disabling Blocks - you would think so, but I'm not sure it actually works the way we would hope.

However, if all three suspects - the icon, the permission and the procedure are nullified, the App should at just stay on screen, doing nothing :)

....unless it is being crashed by a behind-the-scenes action, such as loading images that are not optimised?


ABG

unread,
Dec 18, 2019, 9:31:54 AM12/18/19
to MIT App Inventor Forum
No one else seems to have noticed a Clock for animation.
That's another thing that might be running at startup.

Can you show us the .Timer events for your Clock(s)?

Also, are those Clock(s) enabled or disabled when built?
(Disabled is safer, because there might be other initialization needed
 before the .Timer runs.)

ABG

Chris Ward

unread,
Dec 18, 2019, 9:34:33 AM12/18/19
to MIT App Inventor Forum
With reference to my note above, go through the "Cannot Build or Install APK, or APP installs but Crashes/Freezes" check list on my website and make sure you have not got any of the issues.

Chris Ward

unread,
Dec 18, 2019, 9:37:19 AM12/18/19
to MIT App Inventor Forum
By "The app is complet destroyed", do you mean the GUI Layout is not as expected, or simply that nothing seems to work?

Chris Ward

unread,
Dec 18, 2019, 9:39:38 AM12/18/19
to MIT App Inventor Forum
@ ABG. Good point. I think it would be better if Clock Timers could only be setup in Blocks.

BierGarten100

unread,
Dec 18, 2019, 9:46:38 AM12/18/19
to MIT App Inventor Forum
@ABG
Can you show us the .Timer events for your Clock(s)?

Also, are those Clock(s) enabled or disabled when built?
My Timer Called MenueAnimation and triggered when i press a Button what show like a "Menue Icon". It is a smal .png. i have 3 other .png for the "Animation". The Menue Button takes the Timer Alway Fire and Enable to True.

My Timer Block:

blocks (3).png


@Chris Ward
By "The app is complet destroyed", do you mean the GUI Layout is not as expected, or simply that nothing seems to work?
Its meen ... nothing seems to work. Its show me the GUI but when i will load a text to a label after Initialize. Nothing.

I think the AppInventor Projekt is destroyed and i must make a new one?! o.ô

 

Chris Ward

unread,
Dec 18, 2019, 10:01:40 AM12/18/19
to MIT App Inventor Forum
So, I don't think your project is destroyed :) It does have a few bugs though, self-inflicted by not testing the code regularly as you go along.

Make sure the images you are using are all optimised for Android.

In Designer, Ensure the Clock Timer is not going to start before your buttons tell it to start.

timer.png


BierGarten100

unread,
Dec 18, 2019, 10:14:09 AM12/18/19
to MIT App Inventor Forum
My Timer is realy Disable.
I tell Enable and AlwayFire after clicking my Menue button.

I have delete all my images and try....
Crashing!

With the AI Companion....
Show me the APP Design / GUI and load now the "Starten". (When this only in Initialize)
without the Permission ask.

ABG

unread,
Dec 18, 2019, 10:14:25 AM12/18/19
to MIT App Inventor Forum
(unable to debug further without .aia export)
ABG

Taifun

unread,
Dec 18, 2019, 10:34:18 AM12/18/19
to MIT App Inventor Forum
When i build my app and try open the .apk on my phone,
the app is crashing. I dont know why?

to find out more about the Runtime Error, you can use Logcat

I normally use Eclipse and Logcat there, but if you have installed the App Inventor Software (see also http://appinventor.mit.edu/explore/ai2/setup-emulator.html), you already have everything you need to use logcat...

How to use Logcat
  1. connect your device using USB with your computer
  2. in File Manager go to the App Inventor directory, which is  C:\Program Files\App Inventor or similar
  3. press Shift and right mouse click the subdirectory commands-for-Appinventor to get the context menu
  4. select "open command window here" and you will get a command window of that subdirectory
  5. enter adb logcat *:E and the logcat will start running and log all errors
  6. start your app to elicit the error
  7. copy the log (see below)
To copy your log, right click, click "select all" and enter to copy the complete log into the clipboard, then open Notepad and paste it using ctrl-v.

Taifun

Trying to push the limits of App Inventor! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun. 


BierGarten100

unread,
Dec 18, 2019, 11:02:03 AM12/18/19
to MIT App Inventor Forum
When i will start, tell me AI
"AI2 does not see your device, make sure the cable is plugged in and drivers are correct."
My USB Cable is plugged in but drivers i dont know?!

Taifun

unread,
Dec 18, 2019, 11:06:50 AM12/18/19
to MIT App Inventor Forum

BierGarten100

unread,
Dec 18, 2019, 11:23:15 AM12/18/19
to MIT App Inventor Forum
Ok now...
PS C:\Program Files (x86)\AppInventor\commands-for-appinventor> .\adb logcat *:E
- waiting for device -
E/Zygote  (   33): setreuid() failed. errno: 2
E/Zygote  (   33): setreuid() failed. errno: 17
E/BatteryService(   60): usbOnlinePath not found
E/BatteryService(   60): batteryVoltagePath not found
E/BatteryService(   60): batteryTemperaturePath not found
E/SurfaceFlinger(   60): Couldn't open /sys/power/wait_for_fb_sleep or /sys/power/wait_for_fb_wake
E/EventHub(   60): could not get driver version for /dev/input/mouse0, Not a typewriter
E/EventHub(   60): could not get driver version for /dev/input/mice, Not a typewriter
E/System  (   60): Failure starting core service
E/System  (   60): java.lang.SecurityException
E/System  (   60):      at android.os.BinderProxy.transact(Native Method)
E/System  (   60):      at android.os.ServiceManagerProxy.addService(ServiceManagerNative.java:146)
E/System  (   60):      at android.os.ServiceManager.addService(ServiceManager.java:72)
E/System  (   60):      at com.android.server.ServerThread.run(SystemServer.java:184)
E/SoundPool(   60): error loading /system/media/audio/ui/Effect_Tick.ogg
E/SoundPool(   60): error loading /system/media/audio/ui/KeypressStandard.ogg
E/SoundPool(   60): error loading /system/media/audio/ui/KeypressSpacebar.ogg
E/SoundPool(   60): error loading /system/media/audio/ui/KeypressDelete.ogg
E/SoundPool(   60): error loading /system/media/audio/ui/KeypressReturn.ogg
E/ThrottleService(   60): Could not open GPS configuration file /etc/gps.conf
E/logwrapper(  133): executing /system/bin/tc failed: No such file or directory
E/logwrapper(  137): executing /system/bin/tc failed: No such file or directory
E/logwrapper(  138): executing /system/bin/tc failed: No such file or directory
E/HierarchicalStateMachine(   60): TetherMaster - unhandledMessage: msg.what=3
E/dalvikvm(  282): Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method com.google.appinventor.components.runtime.ButtonBase.setShape


ABG

unread,
Dec 18, 2019, 11:43:41 AM12/18/19
to MIT App Inventor Forum
E/dalvikvm(  282): Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method com.google.appinventor.components.runtime.ButtonBase.setShape

leads me to think that you are doing something strange with Button shapes?

ABG

Taifun

unread,
Dec 18, 2019, 12:00:40 PM12/18/19
to MIT App Inventor Forum
which Android device and Android version are you using for your tests?
Taifun

BierGarten100

unread,
Dec 18, 2019, 12:30:47 PM12/18/19
to MIT App Inventor Forum
leads me to think that you are doing something strange with Button shapes?
haha... no. I have a normal Button without a text but with image.

which Android device and Android version are you using for your tests?
I use my Samsung Galaxy S9 Android version 9 with One UI-Version 1.0 and the Android-Securityupdate Patch by Dez. 1. 2019

Taifun

unread,
Dec 18, 2019, 12:35:00 PM12/18/19
to mitappinv...@googlegroups.com
I have a normal Button without a text but with image.

how large is that image (width and height in pixel)?
what happens, if you temporarily remove that image, build the app and test again?

Taifun

BierGarten100

unread,
Dec 18, 2019, 12:37:04 PM12/18/19
to mitappinv...@googlegroups.com
how large is that image (width and height in pixel)?
That doesn't seem to matter, since I've already tried it without pictures. I deleted all my pictures and the problems were still there.


But for you >> 50x50 <<

Taifun

unread,
Dec 18, 2019, 12:45:12 PM12/18/19
to MIT App Inventor Forum
I now assigned this thread to Evan, probably he knows why such an error could occur...
Could not find class 'android.graphics.drawable.RippleDrawable', referenced from method com.google.appinventor.components.runtime.ButtonBase.setShape

Taifun

BierGarten100

unread,
Dec 18, 2019, 12:48:58 PM12/18/19
to MIT App Inventor Forum
Thank you and the others for the help.
I wait for a solution. :)

BierGarten100

unread,
Dec 18, 2019, 12:56:42 PM12/18/19
to MIT App Inventor Forum
Cringe. The AI tell me now >> Error from Companion: make: no method named `' in class com.google.appinventor.components.runtime.NearField

ABG

unread,
Dec 18, 2019, 1:15:56 PM12/18/19
to MIT App Inventor Forum
Make sure your companion is up to date.
ABG

BierGarten100

unread,
Dec 18, 2019, 1:23:27 PM12/18/19
to MIT App Inventor Forum
I think it is. It has make updates befor i start.
Anyway ^^

ABG

unread,
Dec 18, 2019, 1:45:43 PM12/18/19
to MIT App Inventor Forum
Current Companion version is 2.55.
Also check for errors in all screens' Blocks Editor.
Finally, which other distributions of App Inventor have been used with this project?
ABG

Reply all
Reply to author
Forward
0 new messages