Spanish Mi primer programa en B4xPages... funcionaba. [Solucionado]

carlos7000

Well-Known Member
Licensed User
Longtime User
¡Hola a todos!

Estoy aprendiendo a desarrollar aplicaciones en B4xPages y actualmente estoy trabajando en un programa que tiene como objetivo calcular la ubicación más precisa de donde uno se encuentra.

Cuando abro el programa, comienza a capturar las coordenadas y las promedia, mostrando la posición en un mapa. En un principio, el programa funcionaba correctamente. Sin embargo, después de realizar algunos ajustes, dejó de funcionar. He estado intentando solucionarlo durante un tiempo, pero hasta ahora no he tenido éxito.

En el registro de errores (Log) aparece el mensaje "java.lang.RuntimeException: java.lang.SecurityException: my location requires permission ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION".

Antes de comenzar a capturar las coordenadas en el código, solicito el permiso correspondiente para hacerlo.

B4X:
Dim rp As RuntimePermissions
rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)

rp.CheckAndRequest(rp.PERMISSION_ACCESS_COARSE_LOCATION)
Wait For Activity_PermissionResult (Permission As String, Result As Boolean)

Cualquier ayuda o sugerencia sería muy apreciada. ¡Gracias!

Adjunto el proyecto.

B4X:
Logger connected to:  Blackview BV9300
--------- beginning of main
Copying updated assets files (1)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
java.lang.RuntimeException: java.lang.SecurityException: my location requires permission ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION
    at anywheresoftware.b4a.objects.MapFragmentWrapper$1.onMapReady(MapFragmentWrapper.java:197)
    at com.google.android.gms.maps.zzac.zzb(com.google.android.gms:play-services-maps@@18.1.0:1)
    at com.google.android.gms.maps.internal.zzar.zza(com.google.android.gms:play-services-maps@@18.1.0:6)
    at com.google.android.gms.internal.maps.zzb.onTransact(com.google.android.gms:play-services-maps@@18.1.0:3)
    at android.os.Binder.transact(Binder.java:1064)
    at m.fe.c(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (190408-0):2)
    at com.google.maps.api.android.lib6.impl.bg.run(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (190408-0):2)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7893)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
Caused by: java.lang.SecurityException: my location requires permission ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION
    at com.google.maps.api.android.lib6.impl.bk.J(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (190408-0):11)
    at com.google.android.gms.maps.internal.i.bb(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (190408-0):208)
    at m.ff.onTransact(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (190408-0):4)
    at android.os.Binder.transact(Binder.java:1064)
    at com.google.android.gms.internal.maps.zza.zzc(com.google.android.gms:play-services-maps@@18.1.0:2)
    at com.google.android.gms.maps.internal.zzg.setMyLocationEnabled(com.google.android.gms:play-services-maps@@18.1.0:3)
    at com.google.android.gms.maps.GoogleMap.setMyLocationEnabled(com.google.android.gms:play-services-maps@@18.1.0:1)
    at anywheresoftware.b4a.objects.MapFragmentWrapper$1.onMapReady(MapFragmentWrapper.java:184)
    ... 14 more
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
*** mainpage: B4XPage_Created
*** mainpage: B4XPage_Appear
** Activity (main) Resume **
java.lang.RuntimeException: java.lang.SecurityException: my location requires permission ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION
    at anywheresoftware.b4a.objects.MapFragmentWrapper$1.onMapReady(MapFragmentWrapper.java:197)
    at com.google.android.gms.maps.zzac.zzb(com.google.android.gms:play-services-maps@@18.1.0:1)
    at com.google.android.gms.maps.internal.zzar.zza(com.google.android.gms:play-services-maps@@18.1.0:6)
    at com.google.android.gms.internal.maps.zzb.onTransact(com.google.android.gms:play-services-maps@@18.1.0:3)
    at android.os.Binder.transact(Binder.java:1064)
    at m.fe.c(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (190408-0):2)
    at com.google.maps.api.android.lib6.impl.bg.run(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (190408-0):2)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7893)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
Caused by: java.lang.SecurityException: my location requires permission ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION
    at com.google.maps.api.android.lib6.impl.bk.J(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (190408-0):11)
    at com.google.android.gms.maps.internal.i.bb(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (190408-0):208)
    at m.ff.onTransact(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (190408-0):4)
    at android.os.Binder.transact(Binder.java:1064)
    at com.google.android.gms.internal.maps.zza.zzc(com.google.android.gms:play-services-maps@@18.1.0:2)
    at com.google.android.gms.maps.internal.zzg.setMyLocationEnabled(com.google.android.gms:play-services-maps@@18.1.0:3)
    at com.google.android.gms.maps.GoogleMap.setMyLocationEnabled(com.google.android.gms:play-services-maps@@18.1.0:1)
    at anywheresoftware.b4a.objects.MapFragmentWrapper$1.onMapReady(MapFragmentWrapper.java:184)
    ... 14 more
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
*** mainpage: B4XPage_Created
*** mainpage: B4XPage_Appear
** Activity (main) Resume **
java.lang.RuntimeException: java.lang.SecurityException: my location requires permission ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION
    at anywheresoftware.b4a.objects.MapFragmentWrapper$1.onMapReady(MapFragmentWrapper.java:197)
    at com.google.android.gms.maps.zzac.zzb(com.google.android.gms:play-services-maps@@18.1.0:1)
    at com.google.android.gms.maps.internal.zzar.zza(com.google.android.gms:play-services-maps@@18.1.0:6)
    at com.google.android.gms.internal.maps.zzb.onTransact(com.google.android.gms:play-services-maps@@18.1.0:3)
    at android.os.Binder.transact(Binder.java:1064)
    at m.fe.c(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (190408-0):2)
    at com.google.maps.api.android.lib6.impl.bg.run(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (190408-0):2)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7893)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
Caused by: java.lang.SecurityException: my location requires permission ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION
    at com.google.maps.api.android.lib6.impl.bk.J(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (190408-0):11)
    at com.google.android.gms.maps.internal.i.bb(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (190408-0):208)
    at m.ff.onTransact(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (190408-0):4)
    at android.os.Binder.transact(Binder.java:1064)
    at com.google.android.gms.internal.maps.zza.zzc(com.google.android.gms:play-services-maps@@18.1.0:2)
    at com.google.android.gms.maps.internal.zzg.setMyLocationEnabled(com.google.android.gms:play-services-maps@@18.1.0:3)
    at com.google.android.gms.maps.GoogleMap.setMyLocationEnabled(com.google.android.gms:play-services-maps@@18.1.0:1)
    at anywheresoftware.b4a.objects.MapFragmentWrapper$1.onMapReady(MapFragmentWrapper.java:184)
    ... 14 more
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
*** mainpage: B4XPage_Created
*** mainpage: B4XPage_Appear
** Activity (main) Resume **
java.lang.RuntimeException: java.lang.SecurityException: my location requires permission ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION
    at anywheresoftware.b4a.objects.MapFragmentWrapper$1.onMapReady(MapFragmentWrapper.java:197)
    at com.google.android.gms.maps.zzac.zzb(com.google.android.gms:play-services-maps@@18.1.0:1)
    at com.google.android.gms.maps.internal.zzar.zza(com.google.android.gms:play-services-maps@@18.1.0:6)
    at com.google.android.gms.internal.maps.zzb.onTransact(com.google.android.gms:play-services-maps@@18.1.0:3)
    at android.os.Binder.transact(Binder.java:1064)
    at m.fe.c(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (190408-0):2)
    at com.google.maps.api.android.lib6.impl.bg.run(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (190408-0):2)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7893)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:568)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1045)
Caused by: java.lang.SecurityException: my location requires permission ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION
    at com.google.maps.api.android.lib6.impl.bk.J(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (190408-0):11)
    at com.google.android.gms.maps.internal.i.bb(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (190408-0):208)
    at m.ff.onTransact(:com.google.android.gms.dynamite_mapsdynamite@[email protected] (190408-0):4)
    at android.os.Binder.transact(Binder.java:1064)
    at com.google.android.gms.internal.maps.zza.zzc(com.google.android.gms:play-services-maps@@18.1.0:2)
    at com.google.android.gms.maps.internal.zzg.setMyLocationEnabled(com.google.android.gms:play-services-maps@@18.1.0:3)
    at com.google.android.gms.maps.GoogleMap.setMyLocationEnabled(com.google.android.gms:play-services-maps@@18.1.0:1)
    at anywheresoftware.b4a.objects.MapFragmentWrapper$1.onMapReady(MapFragmentWrapper.java:184)
    ... 14 more
 

Attachments

  • Esstoy Aqui.zip
    12.4 KB · Views: 125

Xfood

Expert
Licensed User
hello friend, i haven't seen the project, but if you use b4xpage, the code should look like this

Wait For B4XPage_PermissionResult(Permission As String, Result As Boolean)
 

TILogistic

Expert
Licensed User
Longtime User
?
B4X:
    'Check location permissions
    rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
    Wait For B4XPage_PermissionResult (Permission As String, PermissionResult As Boolean)
    If PermissionResult Then
        DefineFused
    End If
tips:
1688980175278.png


Manifest:
CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase)
 

TILogistic

Expert
Licensed User
Longtime User
tips:
Agregar
B4X:
#AdditionalJar: com.google.android.gms:play-services-maps
#AdditionalJar: com.google.android.gms:play-services-location
#AdditionalJar: com.android.support:support-v4
 

carlos7000

Well-Known Member
Licensed User
Longtime User
hello friend, i haven't seen the project, but if you use b4xpage, the code should look like this

Wait For B4XPage_PermissionResult(Permission As String, Result As Boolean)

Yes, there was an error there was Activity_PermissionResult

I don't know how it worked before
 

carlos7000

Well-Known Member
Licensed User
Longtime User
?
B4X:
    'Check location permissions
    rp.CheckAndRequest(rp.PERMISSION_ACCESS_FINE_LOCATION)
    Wait For B4XPage_PermissionResult (Permission As String, PermissionResult As Boolean)
    If PermissionResult Then
        DefineFused
    End If
tips:
View attachment 143602

Manifest:
Hola TILogistic

Le agradezco su ayuda, pero necesito una explicación mas extensa.

EL código

B4X:
If PermissionResult Then
    DefineFused
End If

No sé como se me olvido.

Con respecto a:

B4X:
#AdditionalJar: com.google.android.gms:play-services-maps
#AdditionalJar: com.google.android.gms:play-services-location
#AdditionalJar: com.android.support:support-v4

No sé como se borraron 2 líneas. De hecho en una aplicación que compartí hace poco, lo incluye. Creo que el mayor de los errores es que accidentalmente borre esas líneas.

En este punto, la aplicación volvió a funcionar.

Lo de crear una clase. Se como crear una clase. Pero necesito mas información.

El tip de Jetifier. No sé que es o para que sirve. Jetifier me mostró una ventana con una lista de librerías. Hice click en jetifier, pero ni idea de que hice o para que lo hice. La aplicación ya funcionaba. Voy a investigar en el foro para que sirve y como se usa.

Vi su sugerencia de agregar la línea CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase) al Manifiest, lo hice. Sigue funcionando. Por favor, explíqueme para que sirve esa línea

Muchas gracias por su ayuda.
 
Last edited:

TILogistic

Expert
Licensed User
Longtime User
Vi su sugerencia de agregar la línea CreateResourceFromFile(Macro, FirebaseAnalytics.GooglePlayBase) al Manifiest, lo hice. Sigue funcionando. Por favor, explíqueme para que sirve esa línea
Respuestas a los servicios Firebase.

El tip de Jetifier. No sé que es o para que sirve.

#AdditionalJar: com.android.support:support-v4
se explica:

Lo siento pero no tengo mucho tiempo para explicar en detalle.

Solo basta leer y entender.
Saludos.
 

carlos7000

Well-Known Member
Licensed User
Longtime User
Ese post, lo cree porque no encontré una explicación clara.
 
Top