Android Question play services maps crash app

arnold steger

Member
Licensed User
I use the function google map in my app. I have always worked with an older version of b4a, now I made an update to the 9 to use the runtime permission.
I had some difficulties with the installation, but now I can compile the old working project again without error.
Unfortunately, I still have a problem with Appstart. I don't understand where is the problem.

B4X:
Logger verbunden mit:  bq Aquaris X Pro
--------- beginning of crash
--------- beginning of main
Added Separator
Added Separator
Added Separator
Added Separator
Added Separator
Added Separator
Added Separator
** Activity (main) Resume **
** Service (sgps) Start **
WakeLock already held.
java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object anywheresoftware.b4a.objects.collections.Map.Get(java.lang.Object)' on a null object reference
    at anywheresoftware.b4a.objects.MapFragmentWrapper$1.onMapReady(MapFragmentWrapper.java:197)
    at com.google.android.gms.maps.zzab.zza(Unknown Source:2)
    at com.google.android.gms.maps.internal.zzaq.dispatchTransaction(Unknown Source:12)
    at com.google.android.gms.internal.maps.zzb.onTransact(Unknown Source:12)
    at android.os.Binder.transact(Binder.java:627)
    at hp.b(:com.google.android.gms.dynamite_mapsdynamite@17122051@17.1.22 (040408-245988633):14)
    at com.google.android.gms.maps.internal.be.a(:com.google.android.gms.dynamite_mapsdynamite@17122051@17.1.22 (040408-245988633):4)
    at com.google.maps.api.android.lib6.impl.bl.run(:com.google.android.gms.dynamite_mapsdynamite@17122051@17.1.22 (040408-245988633):4)
    at android.os.Handler.handleCallback(Handler.java:790)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6543)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object anywheresoftware.b4a.objects.collections.Map.Get(java.lang.Object)' on a null object reference
    at anywheresoftware.b4a.objects.MapFragmentWrapper$1.onMapReady(MapFragmentWrapper.java:182)
    ... 14 more
** Activity (main) Create, isFirst = true **
LocationManager has been initialized.
Added Separator
Added Separator
Added Separator
Added Separator
Added Separator
Added Separator
** Activity (main) Resume **
LocationManager has been initialized.
*** Service (sgps) Create ***
GPS-Status true
** Service (sgps) Start **
java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object anywheresoftware.b4a.objects.collections.Map.Get(java.lang.Object)' on a null object reference
    at anywheresoftware.b4a.objects.MapFragmentWrapper$1.onMapReady(MapFragmentWrapper.java:197)
    at com.google.android.gms.maps.zzab.zza(Unknown Source:2)
    at com.google.android.gms.maps.internal.zzaq.dispatchTransaction(Unknown Source:12)
    at com.google.android.gms.internal.maps.zzb.onTransact(Unknown Source:12)
    at android.os.Binder.transact(Binder.java:627)
    at hp.b(:com.google.android.gms.dynamite_mapsdynamite@17122051@17.1.22 (040408-245988633):14)
    at com.google.android.gms.maps.internal.be.a(:com.google.android.gms.dynamite_mapsdynamite@17122051@17.1.22 (040408-245988633):4)
    at com.google.maps.api.android.lib6.impl.bl.run(:com.google.android.gms.dynamite_mapsdynamite@17122051@17.1.22 (040408-245988633):4)
    at android.os.Handler.handleCallback(Handler.java:790)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6543)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object anywheresoftware.b4a.objects.collections.Map.Get(java.lang.Object)' on a null object reference
    at anywheresoftware.b4a.objects.MapFragmentWrapper$1.onMapReady(MapFragmentWrapper.java:182)
    ... 14 more
 

arnold steger

Member
Licensed User
i have resolved the problem on app start. init mapfragment i have changed.
now crash when find gps signal, inside the house work all other function.

Logger verbunden mit: bq Aquaris X Pro
--------- beginning of crash
--------- beginning of system
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
LocationManager has been initialized.
Added Separator
Added Separator
** Activity (main) Resume **
Status: PERMISSION_ACCESS_FINE_LOCATIONtrue
*** Service (sgps) Create ***
GPS-Status true
** Service (sgps) Start **
mFragment_Ready
size1
** Receiver (sgps) OnReceive **
** Service (sgps) Start **
WakeLock already held.
Logger verbunden mit: bq Aquaris X Pro
--------- beginning of crash
--------- beginning of system
--------- beginning of main
sgps_gps_locationchanged (java line: 282)
java.lang.IllegalArgumentException: invalid listener: null
at android.location.LocationManager.checkListener(LocationManager.java:2128)
at android.location.LocationManager.removeUpdates(LocationManager.java:916)
at com.rootsoft.locationmanager.LocationManager1.stopMobileListening(LocationManager1.java:133)
at com.Flurnamenatlas.sgps._gps_locationchanged(sgps.java:282)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.gps.GPS$1.onLocationChanged(GPS.java:65)
at android.location.LocationManager$ListenerTransport._handleMessage(LocationManager.java:292)
at android.location.LocationManager$ListenerTransport.-wrap0(Unknown Source:0)
at android.location.LocationManager$ListenerTransport$1.handleMessage(LocationManager.java:237)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6543)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
LocationManager has been initialized.
Added Separator
Added Separator
Added Separator
Added Separator
Added Separator
Added Separator
Added Separator
** Activity (main) Resume **
Status: PERMISSION_ACCESS_FINE_LOCATIONtrue
*** Service (sgps) Create ***
GPS-Status true
** Service (sgps) Start **
mFragment_Ready
size1
** Receiver (sgps) OnReceive **
** Service (sgps) Start **
WakeLock already held.
OnMapLoadedCallback1_MapLoaded
B4X:
Sub Process_Globals
    Dim sGPS As GPS
    Dim sCount As Int
    Dim sLocInit,sGPSStop As Boolean
    Dim sGPSgestartet As Boolean :sGPSgestartet=False
    Dim Notify As Notification
    Dim aktGPSinfo,aktSatinfo As String
    Dim aufz,aufzM As Boolean
    Dim saktLat As String
    Dim saktLon As String
    Dim saktAlt,saltAlt As Double
    Dim saktAcc As Double
    Dim saktSpeed As Double
    Dim sdelayTimer,sKeinSatTimer As Timer
    Dim sdelay,sKeinSat, sAufzOk As Boolean    :sAufzOk=False
    Dim tempDist1,tempDist2 As Location
    Dim alteLatLon As LatLng
    Dim saktDistDiff,saktAltDiff As Double
    Dim sphoneState As PhoneWakeState

End Sub
Sub Service_Create
     sGPS.Initialize("GPS")

     If sGPS.GPSEnabled = False Then
        Main.gpsFrageEinschalten=True
        CallSubDelayed(Main,"FrageGPSaktivieren")
    Else
    StartServiceAt("", DateTime.now + 2 * 1000,True)
    sGPS.Start(1000,5)
    sKeinSatTimer.Initialize("sKeinSatTimer",30000)
    sKeinSatTimer.Enabled=True
     End If
    
    sdelayTimer.Initialize("sdelayTimer",2000)
    sdelayTimer.Enabled=True
    
    Notify.Initialize
    Notify.Icon = "icon"
    Notify.Sound = False
    Notify.Vibrate = False
    Notify.Light= False
    Notify.SetInfo ( "Main.tx130",Main.tx139,Main)
    Notify.Notify(1)

    tempDist1.Initialize2("0.0","0.0")
    tempDist2.Initialize2("0.0","0.0")
    alteLatLon.Initialize("0.0","0.0")
    saltAlt="0"
    saktAltDiff="0"
    
End Sub

Sub Service_Start (StartingIntent As Intent)
    
    sCount = 0
    sGPSgestartet=True
    Main.sGPSinit=True
    Service.StartForeground(1,Notify)
    sphoneState.KeepAlive(False)
    
End Sub

Sub Service_Destroy
If sGPS.GPSEnabled Then
    If sGPS.IsInitialized Then
    sGPS.Stop
    Main.sGPSein=False
    End If
End If
    
    If aufz= True And sWriter.Writer.IsInitialized Then
        sWriter.stopWriter
        Notify.Light=False
        Notify.SetInfo ( "Main.tx130",Main.tx139,"Main")
        Notify.Notify(1)
    End If
    
    sGPSgestartet=False
    Main.sGPSinit=False
    
    Service.StopForeground(1)
    Notify.Cancel(1)

End Sub

Sub sdelayTimer_tick
    sdelay=True
    sdelayTimer.Enabled=False
    
End Sub

Sub sKeinSatTimer_tick
    If sKeinSat=True Then
    ToastMessageShow(Main.tx201, False)
    End If
    
End Sub
Sub gpsFrage
    Main.gpsFrageEinschalten=False
    StartActivity(sGPS.LocationSettingsIntent)

End Sub

Sub GPS_LocationChanged (Location1 As Location)
    sCount = sCount + 1
    
    'Abweichung von 50mt maximal erlaubt
If Location1.Accuracy <=50  Then
    Main.aktLat = NumberFormat((Location1.Latitude),0,10)
    Main.aktLon = NumberFormat((Location1.Longitude),0,10)
    Main.aktAlt = NumberFormat2((Location1.Altitude),0,0,0,False)
    Main.aktAcc = NumberFormat2((Location1.Accuracy),0,0,0,False)
    If Location1.SpeedValid Then
    Main.aktSpeed = NumberFormat2((Location1.Speed),0,2,0,False)
    Else
    Main.aktSpeed = "0.0"
    End If
    
    saktLat = NumberFormat((Location1.Latitude),0,10)
    saktLon = NumberFormat((Location1.Longitude),0,10)
    saktAlt = NumberFormat2((Location1.Altitude),0,0,0,False)
    saktAcc = NumberFormat2((Location1.Accuracy),0,0,0,False)
    If Location1.SpeedValid Then
    saktSpeed = NumberFormat2((Location1.Speed),0,2,0,False)
    Else
    saktSpeed = "0.0"
    End If   
    
    
If aufz= True Then
    tempDist1.Latitude=Location1.Latitude
    tempDist1.Longitude=Location1.Longitude
    If alteLatLon.Latitude>0 And alteLatLon.Longitude>0 Then
    tempDist2.Latitude=alteLatLon.Latitude
    tempDist2.Longitude=alteLatLon.Longitude
    sAufzOk=True
    End If
    If tempDist1.Latitude>0 And tempDist2.Latitude>0 Then
    saktDistDiff=NumberFormat2(tempDist2.DistanceTo(tempDist1),0,1,0,False)
    End If

    If sAufzOk=True Then
    saktAltDiff= saktAlt-saltAlt
    End If

End If
    
    Main.lm.stopMobileListening
    
End If
    
    aktGPSinfo=(Main.aktAlt &Main.tx202& Main.aktAcc & Main.tx203&CRLF& Main.aktLat &","& Main.aktLon &CRLF)
    
    If aufz= True Then
    sWriter.schreibenWriter
    
    alteLatLon.Initialize(saktLat,saktLon)
    saltAlt=saktAlt
    End If
    


    If sLocInit=False Then 'nur das Erste Mal heran zoomen
    CallSubDelayed(Main,"MeinePositionZoomen")
    End If
    
    If Main.GPSfolgen=True Then
    CallSubDelayed(Main,"MeinePositionZoomen")
    End If
            
End Sub

Sub GPS_UserEnabled (Enabled As Boolean)
    Log("GPS-Status "&Enabled)
    Main.sGPSein=Enabled

    If Enabled=False Then
    If aufz= True And sWriter.Writer.IsInitialized Then
        Notify.Light=False
        Notify.SetInfo ( "Main.tx130",Main.tx139,"Main")
        Notify.Notify(1)
        sWriter.stopWriter
        CallSub(Main,"aufzStop_click")
    End If
    End If
    
End Sub

Sub GPS_GpsStatus (Satelliten As List)

    Dim s As Int
    'Dim Satelitentext As String
    Satelitentext = Main.tx204 & CRLF
    s=0
    For i = 0 To Satelliten.Size - 1
        Dim Satellite As GPSSatellite
        Satellite = Satelliten.Get(i)
        Satelitentext = Satelitentext & CRLF & Satellite.Prn & _
            " " & Satellite.Snr & " " & Satellite.UsedInFix & " " & Satellite.Azimuth _
            & " " & Satellite.Elevation
        If Satellite.UsedInFix=True Then s=s+1
        Main.gpsSateliten_s=s
        Main.gpsSateliten_i=i
    Next

    If s>0 Then
        aktSatinfo=Main.tx205& s &Main.tx206& i &Main.tx207
        sKeinSat=False
        sKeinSatTimer.Initialize("sKeinSatTimer",20000)
        sKeinSatTimer.Enabled=True
    Else
        aktSatinfo=Main.tx201
        sKeinSat=True
    End If
        
End Sub
 
Top