Android Question Crash on setLastException.

Robert Valentino

Well-Known Member
Licensed User
Longtime User
I got a crash report today from a user. Is this crash implying that I crashed on a setLastException??

Running v10.2


B4X:
--------- beginning of main
~i:*** Service (starter) Create ***
~i:** Service (starter) Start **
~i:** Activity (main) Create, isFirst =rue **
~i:** Activity (main) Resume **
~l30196610:mFilePicker:true
~l4074842113:cConsent::Initialize
~l5075104257:cConsent::WaitForResult
~l6075104261:cConsent::WaitForResult - /data/data/com.BOBs.BBS/files/Consent.raf
~l7075038721:cConsent::Show Consent
~l8075300865:cConsent::Accept
~l9075235329:cConsent::DoneShowing
~l00524342:Portrait:true Real (X/Y):320 / 432 ~l10524351:Small Screen:true Unsuported:true ~l20524364:IsChromeBook:false ~l30524397:IsMe:false IsTester:false ~l40141033506:cUserPreferences::ReadPreferences - /data/media/0/BOBs/BBS/UserPreferences.raf
~l50141033551:cUserPreferences::ReadPreferences - Does NOT Exist - Creating ~l609895937:cMsgBox::MessageBox
~e:chelp_vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv1 (java line: 330)
[B]~e:java.lang.NullPointerException: Attempt to invoke virtual method 'void anywheresoftware.b4a.BA.setLastException(java.lang.Exception)' on a null object reference[/B]
~e: at com.BOBs.BOBsCommon.ct8textsize._checksize(ct8textsize.java:92)
~e: at com.BOBs.BOBsCommon.ct8textsize._singlelinenolarger(ct8textsize.java:423)
~e: at com.BOBs.BBS.chelp._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv1(chelp.java:330)
~e: at com.BOBs.BBS.main$ResumableSub_Show_Help.resume(main.java:4705)
~e: at com.BOBs.BBS.main._show_help(main.java:4661)
~e: at java.lang.reflect.Method.invoke(Native Method)
~e: at java.lang.reflect.Method.invoke(Method.java:374)
~e: at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
~e: at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1178)
~e: at android.os.Handler.handleCallback(Handler.java:756)
~e: at android.os.Handler.dispatchMessage(Handler.java:95)
~e: at android.os.Looper.loop(Looper.java:135)
~e: at android.app.ActivityThread.main(ActivityThread.java:5314)
~e: at java.lang.reflect.Method.invoke(Native Method)
~e: at java.lang.reflect.Method.invoke(Method.java:374)
~e: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
~e: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
~l704587528:cReplay::SaveReplay - [/data/media/0] /BOBs/BBS/Replay.raf
[B]java.lang.NullPointerException: Attempt to invoke virtual method 'void anywheresoftware.b4a.BA.setLastException(java.lang.Exception)' on a null object reference[/B]
at com.BOBs.BOBsCommon.ct8textsize._checksize(ct8textsize.java:92)
at com.BOBs.BOBsCommon.ct8textsize._singlelinenolarger(ct8textsize.java:423)
at com.BOBs.BBS.chelp._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv1(chelp.java:330)
at com.BOBs.BBS.main$ResumableSub_Show_Help.resume(main.java:4705)
at com.BOBs.BBS.main._show_help(main.java:4661)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:374)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at anywheresoftware.b4a.keywords.Common$11.run(Common.java:1178)
at android.os.Handler.handleCallback(Handler.java:756)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5314)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:374)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
/code]
 

Robert Valentino

Well-Known Member
Licensed User
Longtime User
B4X:
Private Sub CheckSize(TargetView As Object, MultipleLines As Boolean, NumLines As Int) As Boolean
            
            Try
                   If  TargetView = Null Then 
                    Log("SingleLineNoLargerAndPadding")
                          Return True
                   End If
            Catch
                Log("SingleLineNoLargerAndPadding")
                      Return True
            End Try

            Dim lbl As Label = TargetView
            
            Try
                If  MultipleLines Then
                    Dim txtHeight As Int = su.MeasureMultilineTextHeight(lbl, lbl.Text)
                
                    If  NumLines > 0 Then
#if DebugX                    
                        Log("NumLines:" &NumLines &"  txtHeight:" &txtHeight &"  lbl.Height:" &lbl.Height &"  EachLine:" &(lbl.Height / NumLines) &"  TextSize:" &lbl.TextSize)
#end if
                    
                        If  txtHeight <= lbl.Height Or (lbl.Height / NumLines) >= txtHeight Then 
                            Return True
                        End If
                        
                        Return False
                    Else
                        If  txtHeight > lbl.Height Then 
                            Return False
                        End If
                    
                        Return True
                    End If
                Else
                    If  cvs.MeasureStringWidth(lbl.Text, lbl.Typeface, lbl.TextSize) > lbl.Width     Or _
                        su.MeasureMultilineTextHeight(lbl, lbl.Text) > lbl.Height Then 
                        Return False
                    End If
                
                    Return True
                End If
            Catch
                Return False
            End Try
End Sub

Seems to be the highlighted line. But I check for null when I first enter the routine
 
Upvote 0
Top