Apk image file has occured "runtime error"

Hi,all

I have a problem installing apk file into my android smart phone.
JZS_Part2.aia (11.0 KB)

I am trying to display to a label area which read from little file(csv) by 1 second.
So I use "clock" and I read a file by 1 second , it works on the "MIT App inventor".

As a test,I build apk file and install it.But it occured "runtime error" and it does not work.

The reason for I take a interval with a clock ,I want to avoid to an Application Not Responding.

Debugging onto an App inventor is ok,apk is fail. I do not know it.

Would you please give me to resolve this problem? In Clock timer,can I not use a file I/O ?

Thank you.

If you are asking for help, I recommend you to make it as easy for others to be able to help you ...
You probably will get more feedback then...

which means in your case post a screenshot of your relevant blocks...

To download the aia file, upload it to App Inventor, open it, do some bug hunting for you, etc... this takes time, and most people will not do that...
Thank you.

Taifun


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

1 Like

Block debug is ok.It is no problem to run.

How do I debug about apk image built in app inventor on my android smart phone?

Thank you.

I took a quick look at your aia and really don't know where to start.
There are just too many mistakes and inconsistencies.

Only one example:

Search for it in the forum. I and others have created a number of guides and topics on this.

Taifun

If button is pressed,clock1 enable will be true.At that time program started.When Its running program has completed to proceed a files existed,clock1 will detect it and stop a program with checking a counter on the label number and clock1 be set to false.

I will show you detail later.

Thanks.I try it.

No, the app starts with the Screen1.Initialize event.

I am talking about this:

The fact that the double slash // in front of the file name causes it to refer to the assets with Companion is bizarre enough. This will NOT work (I'm sure without having tested it) with the APK.

So as I said and showed before, fix the many bugs and inconsistencies.

1 Like

On Android 9, but almost the same on Android 11+:

:question:
@ewpatton

(Btw, the same on Niotron.)

1 Like

Hi,Taifun-san,Anke-san,and all to view this article.

Thank you a lot information about this.
So I use adb tools and mit app inventor companion carefully, I check my source file
(block) and detail again, so I got this "runtime error " is occured by a basic problem( of me).

My wrong is listed below:
"File1" component of default scope is undefined by myself. Is that "app" or "assets" or other ,I don't check about it. (As result ,"app" is when application error is occued.)

http://ai2.appinventor.mit.edu.ezproxy.canberra.edu.au/reference/components/storage.html#File

According to this article as above,it says " the DefaultScope is set to App".

By this,I set Default Scope is set to "Assets".

Just in case,I set to "Asset" of File1.Scope.

file1

Otherwise,File1 component is set to enable for the both permisstion (Read/Write) on companion,and When I proceed to "ReadFrom " ,except a double slashes from a filename ("//testfile.txt" to "testfile.txt").That becomes it works.

Finally,This case is occued by me with my lack of knowledge about MIT App inventor.
I aporogize to lost your time.

In short,I am an idiot and I have no permission to the file to read in apk file of apps.

I resolve this problem.

Thank you.

What does your app and reading a (text) file from the assets have to do with permissions?
You only confuse the other users by not explaining this in more detail.

As far as I remember your app correctly, no storage permissions are required for your app and should therefore neither be requested nor granted.

Anke-san,

I check about this "runtime error" again and show detail below.

First , I show you about my smartphone environment.
Android version:4.0.4
Mobile Phone:Sony Ericsson SO-03D

It's so old one.

Second, adb environment.
adb version
Android Debug Bridge version 1.0.32

adb devices
List of devices attached
CB5120FNAK device


case1) runtime error occured.

designer

blocks

adb logcat
D/memalloc( 144): /dev/pmem: Allocated buffer base:0x42913000 size:3768320 offset:25276416 fd:52
D/memalloc(15462): /dev/pmem: Mapped buffer base:0x5d945000 size:29044736 offset:25276416 fd:68
I/Adreno200-EGLSUB( 144): CreateImage:893: Android Image
I/Adreno200-EGLSUB( 144): GetImageAttributes:1102: RGBA_8888
I/ActivityManager( 381): Displayed appinventor.ai_gipora_ym.RuntimeErrorOccued/.Screen1: +4s350ms
D/memalloc( 144): /dev/pmem: Freeing buffer base:0x43d96000 size:3768320 offset:21508096 fd:56
D/memalloc( 381): /dev/pmem: Unmapping buffer base:0x6215e000 size:25276416 offset:21508096
D/memalloc( 144): /dev/pmem: Allocated buffer base:0x42913000 size:3768320 offset:21508096 fd:39
D/memalloc(15462): /dev/pmem: Mapped buffer base:0x5f4f8000 size:25276416 offset:21508096 fd:71
I/Adreno200-EGLSUB( 144): CreateImage:893: Android Image
I/Adreno200-EGLSUB( 144): GetImageAttributes:1102: RGBA_8888
I/Adreno200-EGLSUB( 144): CreateImage:893: Android Image
I/Adreno200-EGLSUB( 144): GetImageAttributes:1102: RGBA_8888
D/AudioPolicyManager( 161): setStreamVolume() for output 1 stream 0, volume 0.316229, delay 0
E/AudioHardwareMSM8660( 161): unknown stream
D/AudioPolicyManager( 161): setStreamVolume() for output 1 stream 10, volume 1.000000, delay 0
I/dalvikvm(15462): Could not find method java.nio.file.Paths.get, referenced from method com.google.appinventor.components.runtime.util.FileUtil.copyFile
W/dalvikvm(15462): VFY: unable to resolve static method 34093: Ljava/nio/file/Paths;.get (Ljava/net/URI;)Ljava/nio/file/Path;
D/dalvikvm(15462): VFY: replacing opcode 0x71 at 0x0020
I/dalvikvm(15462): Could not find method android.provider.MediaStore$Downloads.getContentUri, referenced from method com.google.appinventor.components.runtime.util.FileUtil.getContentUriForPath
W/dalvikvm(15462): VFY: unable to resolve static method 1528: Landroid/provider/MediaStore$Downloads;.getContentUri (Ljava/lang/String;)Landroid/net/Uri;
D/dalvikvm(15462): VFY: replacing opcode 0x71 at 0x007c
I/dalvikvm(15462): Could not find method java.nio.file.Paths.get, referenced from method com.google.appinventor.components.runtime.util.FileUtil.moveFile
W/dalvikvm(15462): VFY: unable to resolve static method 34093: Ljava/nio/file/Paths;.get (Ljava/net/URI;)Ljava/nio/file/Path;
D/dalvikvm(15462): VFY: replacing opcode 0x71 at 0x0020
E/AudioHardwareMSM8660( 161): AudioStreamOutMSM72xx: channels
E/AudioHardwareMSM8660( 161): AudioStreamOutMSM72xx : sampleRate
I/dalvikvm(15462): DexOpt: unable to optimize static field ref 0x52bf at 0x32 in Lcom/google/appinventor/components/runtime/util/FileUtil;.copyFile
D/FileOperation(15462): resolvedPath = /android_asset/debug.txt
D/AudioHardwareMSM8660( 161): write(): dec_id = 1 cur_rx = 23
D/AudioHardwareMSM8660( 161): value of device and enable is 23 1 ALSA dev id:20
W/ApplicationContext(15462): Unable to create external files directory
W/System.err(15462): java.lang.NullPointerException
D/ACDB-LOADER( 161): ACDB -> send_audio_cal, acdb_id = 520, path = 0
D/ACDB-LOADER( 161): ACDB -> send_adm_topology
D/ACDB-LOADER( 161): ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TOPOLOGY_ID
D/ACDB-LOADER( 161): ACDB -> send_audtable
D/ACDB-LOADER( 161): ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TABLE
D/ACDB-LOADER( 161): ACDB -> AUDIO_SET_AUDPROC_CAL
D/ACDB-LOADER( 161): ACDB -> send_audvoltable
D/ACDB-LOADER( 161): ACDB -> ACDB_CMD_GET_AUDPROC_GAIN_DEP_VOLTBL_STEP_COPP
D/ACDB-LOADER( 161): ACDB -> AUDIO_SET_AUDPROC_VOL_CAL
D/AudioHardwareMSM8660( 161): addToTable stream 1
W/System.err(15462): at com.google.appinventor.components.runtime.util.FileUtil.isExternalStorageUri(FileUtil.java:979)
W/System.err(15462): at com.google.appinventor.components.runtime.util.FileUtil.getNeededPermission(FileUtil.java:1005)
W/System.err(15462): at com.google.appinventor.components.runtime.util.SingleFileOperation.getPermissions(SingleFileOperation.java:95)
W/System.err(15462): at com.google.appinventor.components.runtime.util.FileOperation.getNeededPermissions(FileOperation.java:195)
W/System.err(15462): at com.google.appinventor.components.runtime.util.FileOperation.run(FileOperation.java:79)
W/System.err(15462): at com.google.appinventor.components.runtime.File.ReadFrom(File.java:592)
W/System.err(15462): at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err(15462): at java.lang.reflect.Method.invoke(Method.java:511)
W/System.err(15462): at gnu.expr.PrimProcedure.apply(PrimProcedure.java:285)
W/System.err(15462): at gnu.mapping.CallContext.runUntilDone(CallContext.java:234)
W/System.err(15462): at gnu.mapping.CallContext.runUntilValue(CallContext.java:298)
W/System.err(15462): at gnu.mapping.MethodProc.applyN(MethodProc.java:113)
W/System.err(15462): at gnu.kawa.reflect.Invoke.applyN(Invoke.java:193)
W/System.err(15462): at gnu.kawa.functions.ApplyToArgs.applyN(ApplyToArgs.java:139)
W/System.err(15462): at gnu.kawa.functions.Apply.applyN(Apply.java:70)
W/System.err(15462): at gnu.mapping.ProcedureN.apply2(ProcedureN.java:39)
W/System.err(15462): at com.google.youngandroid.runtime.callComponentMethod(runtime4000708707235791166.scm:1061)
W/System.err(15462): at appinventor.ai_gipora_ym.RuntimeErrorOccued.Screen1.Button1$Click(Screen1.yail:37) ***
W/System.err(15462): at appinventor.ai_gipora_ym.RuntimeErrorOccued.Screen1$frame.apply0(Screen1.yail:535) ***
W/System.err(15462): at gnu.expr.ModuleBody.applyN(ModuleBody.java:226)
W/System.err(15462): at gnu.expr.ModuleMethod.applyN(ModuleMethod.java:216)
W/System.err(15462): at gnu.kawa.functions.ApplyToArgs.applyN(ApplyToArgs.java:139)
W/System.err(15462): at gnu.kawa.functions.Apply.applyN(Apply.java:70)
W/System.err(15462): at gnu.mapping.ProcedureN.apply2(ProcedureN.java:39)
W/System.err(15462): at appinventor.ai_gipora_ym.RuntimeErrorOccued.Screen1.dispatchEvent(Screen1.yail:10130)
W/System.err(15462): at com.google.appinventor.components.runtime.EventDispatcher.delegateDispatchEvent(EventDispatcher.java:222)
W/System.err(15462): at com.google.appinventor.components.runtime.EventDispatcher.dispatchEvent(EventDispatcher.java:199)
W/System.err(15462): at com.google.appinventor.components.runtime.Button.Click(Button.java:50)
W/System.err(15462): at com.google.appinventor.components.runtime.Button.click(Button.java:42)
W/System.err(15462): at com.google.appinventor.components.runtime.ButtonBase.onClick(ButtonBase.java:780)
W/System.err(15462): at android.view.View.performClick(View.java:3574)
W/System.err(15462): at android.view.View$PerformClick.run(View.java:14293)
W/System.err(15462): at android.os.Handler.handleCallback(Handler.java:605)
W/System.err(15462): at android.os.Handler.dispatchMessage(Handler.java:92)
W/System.err(15462): at android.os.Looper.loop(Looper.java:137)
W/System.err(15462): at android.app.ActivityThread.main(ActivityThread.java:4441)
W/System.err(15462): at java.lang.reflect.Method.invokeNative(Native Method)
W/System.err(15462): at java.lang.reflect.Method.invoke(Method.java:511)
W/System.err(15462): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823)
W/System.err(15462): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
W/System.err(15462): at dalvik.system.NativeStart.main(Native Method)
I/RuntimeErrorAlert(15462): in alert
E/com.google.appinventor.components.runtime.util.RuntimeErrorAlert(15462): No error message available
I/Adreno200-EGLSUB(15462): ConfigWindowMatch:2078: Format RGBA_8888.
D/memalloc( 144): /dev/pmem: Allocated buffer base:0x42913000 size:1036288 offset:3768320 fd:57
D/memalloc(15462): /dev/pmem: Mapped buffer base:0x60e13000 size:4804608 offset:3768320 fd:74
D/memalloc( 144): /dev/pmem: Allocated buffer base:0x42913000 size:1036288 offset:5513216 fd:64
D/memalloc(15462): /dev/pmem: Mapped buffer base:0x61304000 size:6549504 offset:5513216 fd:80
I/Adreno200-EGLSUB( 144): CreateImage:893: Android Image
I/Adreno200-EGLSUB( 144): GetImageAttributes:1102: RGBA_8888
D/AudioHardwareMSM8660( 161): AudioStreamOutMSM72xx::standby()
D/AudioHardwareMSM8660( 161): Deroute pcm stream
D/AudioHardwareMSM8660( 161): deleteFromTable stream 1
D/AudioHardwareMSM8660( 161): value of device and enable is 23 0 ALSA dev id:20
D/memalloc( 144): /dev/pmem: Allocated buffer base:0x42913000 size:1036288 offset:14909440 fd:62
D/memalloc(15462): /dev/pmem: Mapped buffer base:0x61943000 size:15945728 offset:14909440 fd:83
I/Adreno200-EGLSUB( 144): CreateImage:893: Android Image
I/Adreno200-EGLSUB( 144): GetImageAttributes:1102: RGBA_8888
D/AudioPolicyManager( 161): setStreamVolume() for output 1 stream 0, volume 0.316229, delay 0
E/AudioHardwareMSM8660( 161): unknown stream
D/AudioPolicyManager( 161): setStreamVolume() for output 1 stream 10, volume 1.000000, delay 0
I/Form (15462): Form Screen1 got onPause
I/Adreno200-EGLSUB( 144): CreateImage:893: Android Image
I/Adreno200-EGLSUB( 144): GetImageAttributes:1102: RGBA_8888
E/AudioHardwareMSM8660( 161): AudioStreamOutMSM72xx: channels
E/AudioHardwareMSM8660( 161): AudioStreamOutMSM72xx : sampleRate
D/AudioHardwareMSM8660( 161): write(): dec_id = 1 cur_rx = 23
D/AudioHardwareMSM8660( 161): value of device and enable is 23 1 ALSA dev id:20
I/Adreno200-EGLSUB(15280): ConfigWindowMatch:2078: Format RGBA_8888.
D/memalloc( 144): /dev/pmem: Allocated buffer base:0x42913000 size:3768320 offset:39292928 fd:71
D/memalloc(15280): /dev/pmem: Mapped buffer base:0x5f356000 size:43061248 offset:39292928 fd:61
D/memalloc(15462): /dev/pmem: Unmapping buffer base:0x60e13000 size:4804608 offset:3768320
D/memalloc(15462): /dev/pmem: Unmapping buffer base:0x61304000 size:6549504 offset:5513216
D/memalloc(15462): /dev/pmem: Unmapping buffer base:0x61943000 size:15945728 offset:14909440
D/memalloc( 144): /dev/pmem: Freeing buffer base:0x42cab000 size:1036288 offset:3768320 fd:57
D/memalloc( 144): /dev/pmem: Freeing buffer base:0x42e55000 size:1036288 offset:5513216 fd:64
D/ACDB-LOADER( 161): ACDB -> send_audio_cal, acdb_id = 520, path = 0
D/ACDB-LOADER( 161): ACDB -> send_adm_topology
D/ACDB-LOADER( 161): ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TOPOLOGY_ID
D/ACDB-LOADER( 161): ACDB -> send_audtable
D/ACDB-LOADER( 161): ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TABLE
D/ACDB-LOADER( 161): ACDB -> AUDIO_SET_AUDPROC_CAL
D/ACDB-LOADER( 161): ACDB -> send_audvoltable
D/ACDB-LOADER( 161): ACDB -> ACDB_CMD_GET_AUDPROC_GAIN_DEP_VOLTBL_STEP_COPP
D/ACDB-LOADER( 161): ACDB -> AUDIO_SET_AUDPROC_VOL_CAL
D/AudioHardwareMSM8660( 161): addToTable stream 1

on smartphone screen

case2) runtime error resolved.

designer

blocks

adb logcat
D/memalloc( 144): /dev/pmem: Freeing buffer base:0x42913000 size:3768320 offset:0 fd:46
D/memalloc( 381): /dev/pmem: Unmapping buffer base:0x6215e000 size:18771968 offset:15003648
D/memalloc( 144): /dev/pmem: Freeing buffer base:0x43762000 size:3768320 offset:15003648 fd:48
D/memalloc( 144): /dev/pmem: Allocated buffer base:0x42913000 size:3768320 offset:15003648 fd:35
D/memalloc(18824): /dev/pmem: Mapped buffer base:0x5da3d000 size:18771968 offset:15003648 fd:71
I/Adreno200-EGLSUB( 144): CreateImage:893: Android Image
I/Adreno200-EGLSUB( 144): GetImageAttributes:1102: RGBA_8888
D/AudioPolicyManager( 161): setStreamVolume() for output 1 stream 0, volume 0.316229, delay 0
E/AudioHardwareMSM8660( 161): unknown stream
D/AudioPolicyManager( 161): setStreamVolume() for output 1 stream 10, volume 1.000000, delay 0
I/Adreno200-EGLSUB( 144): CreateImage:893: Android Image
I/Adreno200-EGLSUB( 144): GetImageAttributes:1102: RGBA_8888
D/FileOperation(18824): resolvedPath = /android_asset/debug.txt
D/Form (18824): onGlobalLayout(): diffPercent = 0.078125
D/Form (18824): keyboard hidden!
E/AudioHardwareMSM8660( 161): AudioStreamOutMSM72xx: channels
E/AudioHardwareMSM8660( 161): AudioStreamOutMSM72xx : sampleRate
D/AudioHardwareMSM8660( 161): write(): dec_id = 1 cur_rx = 23
D/AudioHardwareMSM8660( 161): value of device and enable is 23 1 ALSA dev id:20
D/ACDB-LOADER( 161): ACDB -> send_audio_cal, acdb_id = 520, path = 0
D/ACDB-LOADER( 161): ACDB -> send_adm_topology
D/ACDB-LOADER( 161): ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TOPOLOGY_ID
D/ACDB-LOADER( 161): ACDB -> send_audtable
D/ACDB-LOADER( 161): ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TABLE
D/ACDB-LOADER( 161): ACDB -> AUDIO_SET_AUDPROC_CAL
D/ACDB-LOADER( 161): ACDB -> send_audvoltable
D/ACDB-LOADER( 161): ACDB -> ACDB_CMD_GET_AUDPROC_GAIN_DEP_VOLTBL_STEP_COPP
D/ACDB-LOADER( 161): ACDB -> AUDIO_SET_AUDPROC_VOL_CAL
D/AudioHardwareMSM8660( 161): addToTable stream 1
D/AudioHardwareMSM8660( 161): AudioStreamOutMSM72xx::standby()
D/AudioHardwareMSM8660( 161): Deroute pcm stream
D/AudioHardwareMSM8660( 161): deleteFromTable stream 1
D/AudioHardwareMSM8660( 161): value of device and enable is 23 0 ALSA dev id:20
^C

on smartphone screen

case3) runtime error resolved.

designer

blocks

adb logcat
I/Adreno200-EGLSUB( 144): CreateImage:893: Android Image
I/Adreno200-EGLSUB( 144): GetImageAttributes:1102: RGBA_8888
I/ActivityManager( 381): Displayed appinventor.ai_gipora_ym.RuntimeErrorOccuedResolved/.Screen1: +196ms
D/memalloc( 381): /dev/pmem: Unmapping buffer base:0x6215e000 size:22540288 offset:18771968
D/memalloc( 144): /dev/pmem: Freeing buffer base:0x43afa000 size:3768320 offset:18771968 fd:48
D/memalloc( 144): /dev/pmem: Allocated buffer base:0x42913000 size:3768320 offset:15003648 fd:41
D/memalloc(19768): /dev/pmem: Mapped buffer base:0x5fe90000 size:18771968 offset:15003648 fd:71
I/Adreno200-EGLSUB( 144): CreateImage:893: Android Image
I/Adreno200-EGLSUB( 144): GetImageAttributes:1102: RGBA_8888
D/AudioPolicyManager( 161): setStreamVolume() for output 1 stream 0, volume 0.316229, delay 0
E/AudioHardwareMSM8660( 161): unknown stream
D/AudioPolicyManager( 161): setStreamVolume() for output 1 stream 10, volume 1.000000, delay 0
D/FileOperation(19768): resolvedPath = /android_asset/debug.txt
I/Adreno200-EGLSUB( 144): CreateImage:893: Android Image
I/Adreno200-EGLSUB( 144): GetImageAttributes:1102: RGBA_8888
D/Form (19768): onGlobalLayout(): diffPercent = 0.078125
D/Form (19768): keyboard hidden!
E/AudioHardwareMSM8660( 161): AudioStreamOutMSM72xx: channels
E/AudioHardwareMSM8660( 161): AudioStreamOutMSM72xx : sampleRate
D/AudioHardwareMSM8660( 161): write(): dec_id = 1 cur_rx = 23
D/AudioHardwareMSM8660( 161): value of device and enable is 23 1 ALSA dev id:20
D/ACDB-LOADER( 161): ACDB -> send_audio_cal, acdb_id = 520, path = 0
D/ACDB-LOADER( 161): ACDB -> send_adm_topology
D/ACDB-LOADER( 161): ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TOPOLOGY_ID
D/ACDB-LOADER( 161): ACDB -> send_audtable
D/ACDB-LOADER( 161): ACDB -> ACDB_CMD_GET_AUDPROC_COMMON_TABLE
D/ACDB-LOADER( 161): ACDB -> AUDIO_SET_AUDPROC_CAL
D/ACDB-LOADER( 161): ACDB -> send_audvoltable
D/ACDB-LOADER( 161): ACDB -> ACDB_CMD_GET_AUDPROC_GAIN_DEP_VOLTBL_STEP_COPP
D/ACDB-LOADER( 161): ACDB -> AUDIO_SET_AUDPROC_VOL_CAL
D/AudioHardwareMSM8660( 161): addToTable stream 1
^C

on smartphone screen


Thus,case1 only have an errors for reading files that I think around a permission and a relevant things.

Thanks anyway.

I think that case3 will be occured a runtime error at first time,because of file compornent does not have write permission to anywhere.

At this time,case3 ran after case2,so "debug.txt" has already existed and be able to read it ,so runtime error may not be occured.

I think that an app need to put a some files to an asset directory or anywhere,file component must be set a write permission on a designer of a companion I think.

If you try to read a text file from the assets by using a double slash // in front of the filename, this is only possible if the FileScope is set to Legacy.

Screenshot

Note:
To access a file from the assets (regardless of media or non-media files) NO storage permissions are needed regardless of the Android version. However, to access a file from the ASD before Android 4.4 (API 19) storage permissions are requested.

1 Like

My app works fine but I am being in debuggi now.

Thanks a lot.