Android Question BCToast Failing after latest update

MrKim

Well-Known Member
Licensed User
Longtime User
UPDATE: It only fails the FIRST time. I put a test Toast immediatly after the initialize. IT failed but the one below did not.

This a B4A only project. NOT B4XPages.
1786241772208.png

1786241799705.png

Fails on this line:
B4X:
            Toast.Show($"[textsize=20]Licensed until: ${A}[/textsize]"$)
Error:
B4X:
*** Service (starter) Create ***
*** Service (starter) Create completed ***
*** Service (starter) Started ***
** Service (starter) Start **
*** Service (starter) Started completed ***
** Activity (main) Create (first time) **
** Activity (main) Resume **
Error occurred on line: 1201 (BCTextEngine)
java.io.FileNotFoundException: /data/user/0/com.ISS.MJL2Testing/files/virtual_assets/emoji-data.txt: open failed: ENOENT (No such file or directory)
    at libcore.io.IoBridge.open(IoBridge.java:574)
    at java.io.FileInputStream.<init>(FileInputStream.java:179)
    at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:205)
    at anywheresoftware.b4a.objects.streams.File.ReadList(File.java:239)
    at com.ISS.MJL2Testing.bctextengine._loaddata(bctextengine.java:2045)
    at com.ISS.MJL2Testing.bctextengine._createglyph(bctextengine.java:1695)
    at com.ISS.MJL2Testing.bctextengine._createglyphfromdefaultcolor(bctextengine.java:1735)
    at com.ISS.MJL2Testing.bctextengine._createglyph(bctextengine.java:1574)
    at com.ISS.MJL2Testing.bctextengine._getkernspacebetweenchars(bctextengine.java:2284)
    at com.ISS.MJL2Testing.bctextengine._createsinglesection(bctextengine.java:2173)
    at com.ISS.MJL2Testing.bctextengine._createunbreakable(bctextengine.java:2340)
    at com.ISS.MJL2Testing.bctextengine._handletextrun(bctextengine.java:3208)
    at com.ISS.MJL2Testing.bctextengine._prepare(bctextengine.java:2848)
    at com.ISS.MJL2Testing.bctextengine._drawtext(bctextengine.java:980)
    at com.ISS.MJL2Testing.bblabel._redraw(bblabel.java:192)
    at com.ISS.MJL2Testing.bblabel._parseanddraw(bblabel.java:157)
    at com.ISS.MJL2Testing.bblabel._settext(bblabel.java:79)
    at com.ISS.MJL2Testing.bctoast$ResumableSub_Show.resume(bctoast.java:233)
    at com.ISS.MJL2Testing.bctoast._show(bctoast.java:115)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:209)
    at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
    at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:281)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:150)
    at anywheresoftware.b4a.BA$2.run(BA.java:380)
    at android.os.Handler.handleCallback(Handler.java:958)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:230)
    at android.os.Looper.loop(Looper.java:319)
    at android.app.ActivityThread.main(ActivityThread.java:8919)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)
    at libcore.io.Linux.open(Native Method)
    at libcore.io.ForwardingOs.open(ForwardingOs.java:574)
    at libcore.io.BlockGuardOs.open(BlockGuardOs.java:274)
    at libcore.io.ForwardingOs.open(ForwardingOs.java:574)
    at android.app.ActivityThread$AndroidOs.open(ActivityThread.java:8782)
    at libcore.io.IoBridge.open(IoBridge.java:560)
    ... 37 more
Compiles fine, no errors.
 
Last edited:

MrKim

Well-Known Member
Licensed User
Longtime User
Uninstalled and reinstalled. Two devices. Pixel 7 and Samsung Galaxy Tab A7 lite. Used Both USB and B4A-Bridge
Still the same issue.
I'm going to bed.
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
Always recommended when facing annoying bugs.

I will see if I can reproduce it.
Reinstalled B4A-13.40 over beta. It worked fine. Reinstalled Beta over B4A-13.40 and it worked fine.
So probably a bad install. The one thing I did not do is test the beta after rebooting so that might have been it.
Thanks for your help.
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
Always recommended when facing annoying bugs.

I will see if I can reproduce it.
Well, it is partially? - Fixed. I no longer get the problem on the pixel 7 but it is still there on the Samsung Galaxy Tab A7 lite and very consistent. I uninstalled the app and reinstalled - still there.
It happens only the FIRST time toast is called. After that it works fine.
I was able to work around the problem by simply calling toast immediately after initializing it.
It always fails but only the once.
B4X:
        Toast.Initialize(Activity)
        'TESTING ONLY!!!
        Try
            Toast.Show("TEst")
        Catch
            Log(LastException.Message)
        End Try
I have another toast on a different activity that has no issue so evidently it is only the first time on any toast.
Log(File.exists(File.DirAssets, "emoji-data.txt")) in release mode always returns false.
I notice I have a lot of copies of this file in windows but nothing this year. It is always in ...\Object\b4xLibs\files
I I just discovered I am getting the same error. When using BCTextEngine.
This always fails. Not just the first time.

B4X:
    Dim BTE As BCTextEngine
    Private BBText As BBLabel
.
    Dim P As B4XView = XUI.CreatePanel("")
.
    BTE.Initialize(P)
    BBText.Text = Text

.
And again, works fine on Pixel 7, fails on the Samsung.
 
Last edited:
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
It fails in release mode:
1786564124388.png

The first error is the one that happens with Toast. The second two happen with bctextengine/bblabel.
Note that I tested with both USB and B4Abridge.
This morning it is no longer working with either device and I figured out why it was working with the Pixel (and I imagine this would apply to the tablet as well).
I re-installed 3.4 - works fine. Then re-install Beta - it runs fine IN DEBUG ONLY. In prod mode it will always fail with the beta version.
Note that I did not clean the app.
Install 3.4, run app in debug mode and it works,
Install Beta,, run in debug mode and it works.
Run in prod mode and it fails.

Here is the list of libs in this app in case that will help:
1786566309473.png
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
I can tell you what fixes the problem. I did not have BCTextEngine as one of the libraries in my app. I disassembled BCToast and noticed that this was included in the lib so I added it to my app and the problem went away. I thought libs in b4xlibs were already included so this shouldn't be necessary?

I should also mention that this app has a second BCToast called BCToastWV. I created this library from the first one and has second parameter that allow you to add a B4Xview to the message. Perhaps they are interacting in some way although the activity containing BCToastWV is never used before the problem arises. I have attached this lib as well.
 

Attachments

  • BCToastWV.b4xlib
    5.1 KB · Views: 3
Upvote 0
Top