Android Question Fatal Exception: java.lang.RuntimeException

AHilberink

Active Member
Licensed User
Longtime User
Hi,

I got the following error only on one smartphone. With the same data, other smartphones and tablets are working without problems:

B4X:
          Fatal Exception: java.lang.RuntimeException: Object should first be initialized (List).
       at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
       at anywheresoftware.b4a.objects.collections.List.getSize(List.java:129)
       at ciris.chauffeur.bbcodeparser._createruns(bbcodeparser.java:169)
       at ciris.chauffeur.bbcodeview._parseanddraw(bbcodeview.java:530)
       at ciris.chauffeur.bbcodeview._settext(bbcodeview.java:605)
       at ciris.chauffeur.hoofdscherm._tekst(hoofdscherm.java:10609)
       at ciris.chauffeur.hoofdscherm$ResumableSub_Activity_Resume.resume(hoofdscherm.java:1353)
       at ciris.chauffeur.hoofdscherm._activity_resume(hoofdscherm.java:1318)
       at java.lang.reflect.Method.invoke(Method.java)
       at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
       at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
       at ciris.chauffeur.hoofdscherm.afterFirstLayout(hoofdscherm.java:114)
       at ciris.chauffeur.hoofdscherm.access$000(hoofdscherm.java:20)
       at ciris.chauffeur.hoofdscherm$WaitForLayout.run(hoofdscherm.java:86)
       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(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

The bbcode I use is:
Global: Private bbOpdracht As BBCodeView

B4X:
    OpdrachtTekst=EigenFuncties.ReplaceBcTextSize(OpdrachtTekst,TextSize-1)
    bbOpdracht.Text=OpdrachtTekst

    '>>>>>> Uitrekening hoeveel regels en dan hoogte variabel maken voor zoveel mogelijk toelichting
    Dim Counter As Int = OpdrachtTekst.Length-OpdrachtTekst.Replace(CRLF,"").Length
    bbOpdracht.mBase.Height=(30+((16-TextSize)*8))*(Counter+1)
    Dim BottomWv As Int=WvOpdracht.Top+WvOpdracht.Height
    WvOpdracht.Top=bbOpdracht.mBase.Top+bbOpdracht.mBase.Height   
    If(WvOpdracht.Top+WvOpdracht.Height>BottomWv) Then WvOpdracht.Height=WvOpdracht.Height-((WvOpdracht.Top+WvOpdracht.Height)-BottomWv)
    WvOpdracht.LoadHtml(HtmlToelichting)

And this part:
B4X:
        bbOpdracht.mBase.Color=Starter.Kleurschema1.Get("Achtergrond")
        bbOpdracht.sv.Color=Starter.Kleurschema1.Get("Achtergrond")
        bbOpdracht.sv.ScrollViewInnerPanel.Color=Starter.Kleurschema1.Get("Achtergrond")
        bbOpdracht.Text=EigenFuncties.ReplaceBcTextColor(bbOpdracht.Text,Starter.Kleurschema1.Get("Tekst"))

Someone can help me to find the List who probably gives this error? Could it be inside bbcodeview?

Difficult to find, because all my devices are working correctly, but my client not.

Kind regards,
André
 

drgottjr

Expert
Licensed User
Longtime User
i like your optimistic outlook ("only on one smartphone"). yet. 🤞

just to back up for a second, methods that return a list can return null. there is nothing intrinsically wrong
with this. the problem occurs when you try to use that list. (the real problem occurs by not testing whether
the list is initialized before using it...)

to answer your question regarding bbcodeview, there are 3 lists declared in bbcodeview. its parseanddraw sub doesn't return a list, but it does assign one. that method is mentioned in the error log, but it's possible (if not probable that the real error occurred earlier. for me, lines 6 and 7 in the log entries you show could be likely candidates. errors there might be passed to parseanddraw, thus resulting in a null list's being created.

fortunately, bbcodeview can be modified by you at least to trap for a null list, but i don't know if you're up to that task. without access to the actual device that crashes, it could be a lengthy process since you'd have to keep sending updated versions of the app to your client for him to test. it isn't difficult to modify b4xlib modules.
 
Upvote 0
Top