Android Question Solved - How do I find this bug in my app

tsteward

Well-Known Member
Licensed User
Longtime User
I'd appreciate some help narrowing down / finding what view or whatever it is causing this crash.
Something to do with a B4Xbitmap not being initialized but I just can't find it.
 

Attachments

  • lishi.assistand.tony.stewardgmail.com_issue_0bf7636a7cdbc2ab98550c543417fd40_crash_session_67E...txt
    22 KB · Views: 29
  • ObfuscatorMap.txt
    263.6 KB · Views: 21

Alexander Stolte

Expert
Licensed User
Longtime User
but I just can't find it.
the error is in the b4xmainpage module in the B4XPage_Appear sub.
You are using a b4ximageview and assigns a picture where the crash occurs.

This is the stack trace:
B4X:
Fatal Exception: java.lang.RuntimeException: java.lang.RuntimeException: Object should first be initialized (B4XBitmap).
       at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1750)
       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)

Caused by java.lang.RuntimeException: Object should first be initialized (B4XBitmap).
       at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
       at lishi.assistand.tony.stewardgmail.com.xuiviewsutils._vv4(xuiviewsutils.java:139)
       at lishi.assistand.tony.stewardgmail.com.b4ximageview._setvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv1(b4ximageview.java:171)
       at lishi.assistand.tony.stewardgmail.com.b4xmainpage._vvvvvvvvvv6(b4xmainpage.java:4136)
       at lishi.assistand.tony.stewardgmail.com.b4xmainpage$ResumableSub_B4XPage_Appear.resume(b4xmainpage.java:311)
       at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1748)
       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)
 
Upvote 0

tsteward

Well-Known Member
Licensed User
Longtime User
The only bitmap if HamburgerIcon
I have code exactly as in this post from Erel

In B4XPage_Create I Have
B4X:
#if b4a
    HamburgerIcon = xui.LoadBitmapResize(File.DirAssets, "hamburger.png", 32dip, 32dip, True)
    #End If

B4X:
Private Sub B4XPage_Appear
    #if b4a
    Sleep(0)
    B4XPages.GetManager.ActionBar.RunMethod("setDisplayHomeAsUpEnabled", Array(True))
    Dim bd As BitmapDrawable
    bd.Initialize(HamburgerIcon)
    B4XPages.GetManager.ActionBar.RunMethod("setHomeAsUpIndicator", Array(bd))
    SetActionBarCustomViewState(False)
    Dim cs As CSBuilder
    Dim tmpuser As String = ""
    If Options1.IsInitialized Then
        tmpuser = Options1.Get("UserName")
    End If
    If tmpuser = "Username" Or tmpuser.Length < 1 Then
        cs.Initialize.Color(xui.Color_Red).Append("Welcome ").PopAll
    Else
        cs.Initialize.Color(xui.Color_Red).Append("Welcome " & tmpuser).PopAll
    End If
    SetSubtitle(cs)  'subtitle can be text also
    #end if
    If B4XComboBoxRecent.IsInitialized Then
        If B4XComboBoxRecent.SelectedIndex = 1 Then
            btnRefresh_Click
        End If
    End If
    MessagesCheck
    
End Sub
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Private Sub B4XPage_Appear
Is this the complete code from the event? The question is whether the “setHomeAsUpIndicator” function uses a B4XImageView, otherwise the error message with the code makes no sense.
 
Upvote 0

tsteward

Well-Known Member
Licensed User
Longtime User
I managed to get it to crash on my wifes phone in debug mode and get the following error
Suggesting the problem is in XUIViewsUtils or my use of it I guess.

*** Receiver (firebasemessaging) Receive (first time) ***
Error occurred on line: 66 (XUIViewsUtils)
java.lang.RuntimeException: Object should first be initialized (B4XBitmap).
at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67)
at lishi.assistand.tony.stewardgmail.com.xuiviewsutils._setbitmapandfill(xuiviewsutils.java:116)
at lishi.assistand.tony.stewardgmail.com.b4ximageview._setbitmap(b4ximageview.java:67)
at lishi.assistand.tony.stewardgmail.com.b4xmainpage._messagescheck(b4xmainpage.java:534)
at lishi.assistand.tony.stewardgmail.com.b4xmainpage$ResumableSub_B4XPage_Appear.resume(b4xmainpage.java:446)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
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:201)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1748)
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:9063)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:588)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Line 66 in XUIViewsUtil is: ImageView.SetBitmap(Bmp)
B4X:
'Sets a bitmap and sets the gravity to Fill.
Public Sub SetBitmapAndFill (ImageView As B4XView, Bmp As B4XBitmap)
    ImageView.SetBitmap(Bmp)
    Dim iiv As ImageView = ImageView

Check the lines where you use XUIViewsUtils.SetBitmapAndFill(ImageView, Bitmap)
Either ImageView or Bitmap seems not to be initialized.
 
Upvote 0

tsteward

Well-Known Member
Licensed User
Longtime User
Found it - THANK YOU both for your help
It was infact a bitmap I declared earlier not working so I added the losdbitmap directly on the line that was faulty.

I'll look into it further tonight.
Found it by putting log statements everywhere until I found where it crashed
 
Last edited:
Upvote 0
Top