Android Question Newbie - Why the project doesn't run beause Main.bal

oehrle

New Member
Hi there. I'm new here and I tried my fist GUI, play around.
But the program doesn't run on my smartphone (Android 4.0.4)

Here are the short code in Main:

B4X:
#Region  Project Attributes
    #ApplicationLabel: FirstUI
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private btn_Aenderung As Button
    Private lbl_BezButton As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("MAIN")
    'Msgbox("Welcome to B4A!", "")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub btn_Aenderung_Click
    
End Sub


Here is the protocol:

B4X:
Copying updated assets files (1)
** Activity (main) Create, isFirst = true **
Error occurred on line: 31 (Main)
java.io.FileNotFoundException: /data/data/b4a.FirstUI/files/virtual_assets/main.bal: open failed: ENOENT (No such file or directory)
    at libcore.io.IoBridge.open(IoBridge.java:419)
    at java.io.FileInputStream.<init>(FileInputStream.java:78)
    at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:204)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:82)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at b4a.FirstUI.main.afterFirstLayout(main.java:104)
    at b4a.FirstUI.main.access$000(main.java:17)
    at b4a.FirstUI.main$WaitForLayout.run(main.java:82)
    at android.os.Handler.handleCallback(Handler.java:605)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4441)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
    at libcore.io.Posix.open(Native Method)
    at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
    at libcore.io.IoBridge.open(IoBridge.java:403)
    ... 24 more
** Activity (main) Resume **




I don't know, why the debugger bluster on line 31 at Activity.LoadLayout("MAIN")
Main.bal is in the file directory available.

Has anybody an idea?
 

emexes

Expert
Licensed User
I thought maybe it was the upper/lower-case of the filenames, but I tried various mismatches here and they all worked ok. So, just to confirm: does MAIN.bal show up in the Files tab on the right-hand side of the IDE, like:

upload_2019-3-31_17-3-0.png
 
Upvote 0

emexes

Expert
Licensed User
Although interestingly, your log says:
Copying updated assets files (1)
** Activity (main) Create, isFirst = true **
Error occurred on line: 31 (Main)
java.io.FileNotFoundException: /data/data/b4a.FirstUI/files/virtual_assets/main.bal: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:419)
at java.io.FileInputStream.<init>(FileInputStream.java:78)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:204)
and mine says:
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 31 (Main)
java.io.FileNotFoundException: /data/user/0/b4a.muck.balcase/files/virtual_assets/maine.bal (No such file or directory)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:146)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:204)
and the differences could be just because we are using different versions of Android and B4A, but... yours says "updated assets" which makes me think that perhaps something missed the update boat, so I'd first try each of:

1/ Tools menu, Clean Project, then F5 to give it a go
2/ Add #DebuggerForceFullDeployment into #Region Project Attributes, then F5 to give it a go
3/ Add #DebuggerForceStandardAssets into #Region Project Attributes, then F5 to give it a go
4/ Uninstall the app, then... F5 to give it a go
 
Upvote 0

oehrle

New Member
Hi emexes, thanks for your help.
Now it is running.
I did point 1, renamed "Main.bal" to "main.bal", did point 2 - 4, it was running. Removed point 2, 3 it rans also :).

All fine. Now I have to look for declare variables, rename labels at button_click to get the correct feeling for basic-syntax. Normally I program in C#.
 
Upvote 0

emexes

Expert
Licensed User
Removed point 2, 3 it ran also :)
If the problem was that somehow a file had previously missed being updated, then it might still be point 2 or 3 that fixed the problem by forcing that file to the phone, after which point 2 or 3 would no longer be required. So, perhaps *now* it looks like they were not what fixed the problem, but... perhaps they were.

That's a long way of saying: if the problem happens again, I wouldn't skip points 2 or 3 during the fix process ;-)

edit: that'd be why I suggested giving it a go after each step, to help pinpoint which step actually cured the problem. All's well that ends well, though, so no worries.

ps: troubleshooters.com is an excellent read for when you're out in the coding jungle fighting bugs by yourself.
 
Last edited:
Upvote 0
Top