Android Question Crashlytics Fatal Exception: java.lang.IllegalStateException

ntuser04

Member
Licensed User
Crashlytics gave me the following crash report. I have two Android devices that I test the application with and I am not able to replicate the crash. The app does not crash on my test devices but in Crashlytics I get a lot of these crashes and on devices that are not old. Please assist.

java.lang.IllegalStateException: at com.google.android.gms.common.internal.Preconditions.checkState(com.google.android.gms: play-services-basement@@17.5.0:29)
at com.google.android.gms.maps.model.LatLngBounds$Builder.build (Unknown Source:21)
at uk.co.martinpearman.b4a.com.google.android.gms.maps.model.LatLngBoundsBuilder.Build (LatLngBoundsBuilder.java:13)
at org.thebus.hea.routesactivity$ResumableSub_GetTripShape.resume (routesactivity.java:1205)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent (BA.java:267)
at anywheresoftware.b4a.BA.raiseEvent2 (BA.java:207)
at anywheresoftware.b4a.keywords.Common$11.run (Common.java:1178)
at android.os.Handler.handleCallback (Handler.java:938)
at android.os.Handler.dispatchMessage (Handler.java:99)
at android.os.Looper.loop (Looper.java:246)
at android.app.ActivityThread.main (ActivityThread.java:8506)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1130)

Brand: Samsung
Model: Samsung Galaxy s10+
Orientation: Vertical
RAM available: 7,680 MB (7,459 MB)
Android Version: Android 9 (SDK 28)
Android 10 (SDK 29)
Android 11 (SDK 30)

B4X:
Sub GetTripShape
    Dim urlstring As String = "https://my.api.here"
    urlstring = urlstring & "/?key=" & Main.API_KEY_OTS
    urlstring = urlstring & "&shape_id=" & shapeID
    'Log(urlstring)
            
    Dim job As HttpJob
    job.Initialize("",Me)
    job.Download(urlstring)

    Dim line As Polyline
    Dim pointlist As List
    Dim point As LatLng
    line = gmap.AddPolyline
    pointlist.Initialize
    
    Wait For (job) JobDone(job As HttpJob)
    If job.Success Then
        Log("good media retrieve - routes")
        
        jobdata = job.GetString
        'Log(jobdata)
        
        Dim parser As JSONParser
        parser.Initialize(jobdata)
        Dim rootvar As Map = parser.NextObject
        Dim data As List = rootvar.Get("DataRows")
        For Each coldata As Map In data
            point.Initialize(coldata.Get("shape_pt_lat"),coldata.Get("shape_pt_lon"))
            pointlist.Add(point)
            TripBoundsBuilder.Include(point)
        Next
    End If
    
    line.Points = pointlist
    Dim tripbounds As LatLngBounds = TripBoundsBuilder.Build
    gmapx.AnimateToBounds(gmap, tripbounds, 40)

    job.Release
    
    line.Color = Colors.Blue
    
    CallSubDelayed(Me, "GetTripShape_Complete")
End Sub
 

ntuser04

Member
Licensed User
In Sub Activity_Create I have the following where GetTripShape (from the crashlytics error) is being called. I think the program is already waiting for the mapfragment to be ready in line four of the code snippet I've included in this comment.

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("RoutesActivityLayout")
    
    Wait For mapRoutesActivity_Ready
    gmap = mapRoutesActivity.GetMap
    
    Dim OnInfoWindowClickListener As OnInfoWindowClickListener
    OnInfoWindowClickListener.Initialize("OnInfoWindowClickListener")
    gmapx.SetOnInfoWindowClickListener(gmap, OnInfoWindowClickListener)
    
    TripBoundsBuilder.Initialize
    
    gmap.Clear

    GetTripShape
    Wait For GetTripShape_Complete
 
Upvote 0

ntuser04

Member
Licensed User
I'll add in the Try / Catch around the function call and monitor the Google Analytics for a few days and hopefully it will resolve it. Thanks!
 
Upvote 0

ntuser04

Member
Licensed User
I checked my Google crash logs and found that I still get the same crash error but less. Here is the modifications I made from the last post. Is there somewhere else I should be calling the Try / Catch? The only line from the error message that references anywhere in my code is "at org.thebus.hea.routesactivity$ResumableSub_GetTripShape.resume (routesactivity.java:1205)" and I've put that function call into a Try / Catch.

B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("RoutesActivityLayout")
    
    Wait For mapRoutesActivity_Ready
    gmap = mapRoutesActivity.GetMap
    
    Dim OnInfoWindowClickListener As OnInfoWindowClickListener
    OnInfoWindowClickListener.Initialize("OnInfoWindowClickListener")
    gmapx.SetOnInfoWindowClickListener(gmap, OnInfoWindowClickListener)
    
    TripBoundsBuilder.Initialize
    
    gmap.Clear

    Try
        GetTripShape
        Wait For GetTripShape_Complete
    Catch
        Log("Trip Shape error occurred")
        Log(LastException)
    End Try
 
Upvote 0
Top