Android Question Error in this line: Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)

MarianoDuk

Member
Licensed User
Hello, please apologize my english, i am doing an B4A app and i need to track use gps coordinates.

I did it in the past without problem, but now i am getting an error exactly in this line:
B4X:
Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)

I added the standard starter module to my app...

i added this 2 lines in the manifest (dont know if really needed);
B4X:
AddManifestText(<uses-feature android:name="android.hardware.location.gps"/>)
AddPermission(android.permission.ACCESS_FINE_LOCATION)

My targetSdkVersion i set to "29".

In my main module i have this lines (related to gps):
B4X:
Public Sub LocationChanged(Location1 As Location)
    LaLati = Location1.Latitude
    LaLong = Location1.Longitude
End Sub

Sub GpsStatus(Satellites As List)
    If Starter.GPS1.GPSEnabled=False Then
        LaLati=""
        LaLong=""
    End If
End Sub

Sub Activity_PermissionResult (Permission As String, Result As Boolean)
    If Permission = Starter.rp.PERMISSION_ACCESS_FINE_LOCATION Then
        If Result Then CallSub(Starter, "StartGPS")
    End If
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    CallSub(Starter, "StopGPS")
End Sub

And when i need to check if GPS is ok, i use this:
B4X:
    If Starter.GPS1.GPSEnabled = False Then
        ToastMessageShow("PASO 1: Active la Ubicación en su dispositivo" & CRLF & "PASO 2: Verifique que el Modo de Ubicación no esté en 'Ahorro de batería'" & CRLF & "PASO 3: Otorgue permiso a esta aplicación (ingrese a 'Permisos en las apps')", True)
        StartActivity(Starter.GPS1.LocationSettingsIntent) 'Will open the relevant settings screen.
    Else
        Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)
        Wait For Activity_PermissionResult (permission As String, Result As Boolean)
        If Result Then CallSubDelayed(Starter, "StartGPS")
    End If

If "location"is disabed on my phone, no problem... when i activate location then that line i commented (Starter.rp.CheckAndRequest(Starter.rp.PERMISSION_ACCESS_FINE_LOCATION)) gives an error.

I know there is a lot of code about gps, but i cant figure out what is the problem...

Can you please help me? Thanks.
 

MarianoDuk

Member
Licensed User
By the way, my log permission wndows, look like this:
log_permisos.png
 
Upvote 0

MarianoDuk

Member
Licensed User
And the error seems to be this:
B4X:
Caused by: java.lang.ClassNotFoundException:
Didn't find class "androidx.core.content.ContextCompat" on path: DexPathList[[zip file ........
 
Upvote 0

MarianoDuk

Member
Licensed User
SOLVED! I think...
I downloaded the 2 zip files for sdk (370mb) on a new C:\Android-B4A\ folder and point my Android path to that folder using "Android30" version, and the it work!
So... i can unistall all previus sdk? This new folder are 370mb size... my previous sdk foler (with Android 26 and 29) is 27GB size!
 
Upvote 0
Top