Geolocator permission
Duplicate Check
- [x] I have searched the opened issues and there are no duplicates
Describe the bug
I can't get geolocator permissions on android 14.
dependencies = [ "flet==0.27.6", "flet-geolocator", ]
Code sample
Code
import flet as ft
async def main(page: ft.Page):
page.scroll = ft.ScrollMode.ADAPTIVE
page.appbar = ft.AppBar(title=ft.Text("Geolocator Tests"))
def handle_position_change(e):
page.add(ft.Text(f"New position: {e.latitude} {e.longitude}"))
gl = ft.Geolocator(
location_settings=ft.GeolocatorSettings(
accuracy=ft.GeolocatorPositionAccuracy.LOW
),
on_position_change=handle_position_change,
on_error=lambda e: page.add(ft.Text(f"Error: {e.data}")),
)
page.overlay.append(gl)
settings_dlg = lambda handler: ft.AlertDialog(
adaptive=True,
title=ft.Text("Opening Location Settings..."),
content=ft.Text(
"You are about to be redirected to the location/app settings. "
"Please locate this app and grant it location permissions."
),
actions=[ft.TextButton(text="Take me there", on_click=handler)],
actions_alignment=ft.MainAxisAlignment.CENTER,
)
async def handle_permission_request(e):
p = await gl.request_permission_async(wait_timeout=60)
page.add(ft.Text(f"request_permission: {p}"))
async def handle_get_permission_status(e):
p = await gl.get_permission_status_async()
page.add(ft.Text(f"get_permission_status: {p}"))
async def handle_get_current_position(e):
p = await gl.get_current_position_async()
page.add(ft.Text(f"get_current_position: ({p.latitude}, {p.longitude})"))
async def handle_get_last_known_position(e):
p = await gl.get_last_known_position_async()
page.add(ft.Text(f"get_last_known_position: ({p.latitude}, {p.longitude})"))
async def handle_location_service_enabled(e):
p = await gl.is_location_service_enabled_async()
page.add(ft.Text(f"is_location_service_enabled: {p}"))
async def handle_open_location_settings(e):
p = await gl.open_location_settings_async()
page.close(location_settings_dlg)
page.add(ft.Text(f"open_location_settings: {p}"))
async def handle_open_app_settings(e):
p = await gl.open_app_settings_async()
page.close(app_settings_dlg)
page.add(ft.Text(f"open_app_settings: {p}"))
location_settings_dlg = settings_dlg(handle_open_location_settings)
app_settings_dlg = settings_dlg(handle_open_app_settings)
page.add(
ft.Row(
wrap=True,
controls=[
ft.OutlinedButton(
"Request Permission",
on_click=handle_permission_request,
),
ft.OutlinedButton(
"Get Permission Status",
on_click=handle_get_permission_status,
),
ft.OutlinedButton(
"Get Current Position",
on_click=handle_get_current_position,
),
ft.OutlinedButton(
"Get Last Known Position",
visible=False if page.web else True,
on_click=handle_get_last_known_position,
),
ft.OutlinedButton(
"Is Location Service Enabled",
on_click=handle_location_service_enabled,
),
ft.OutlinedButton(
"Open Location Settings",
visible=False if page.web else True,
on_click=lambda e: page.open(location_settings_dlg),
),
ft.OutlinedButton(
"Open App Settings",
visible=False if page.web else True,
on_click=lambda e: page.open(app_settings_dlg),
),
],
)
)
ft.app(main)
To reproduce
No location permissions are defined in the manifest,
Expected behavior
No response
Screenshots / Videos
Captures
[Upload media here]
Operating System
Windows
Operating system details
windows 10
Flet version
0.27.6
Regression
Yes, it used to work in a previous Flet version (please specify the version in additional details)
Suggestions
No response
Logs
Logs
[Paste your logs here]
Additional details
No response
Use Geolocator classes from flet_geolocator module, like in the example here: https://github.com/flet-dev/flet-geolocator?tab=readme-ov-file#example
Use Geolocator classes from
flet_geolocatormodule, like in the example here: https://github.com/flet-dev/flet-geolocator?tab=readme-ov-file#example
pyproject.toml dependencies flet-geolocator==0.1.0
Uninstall the app from the app before deploying an updated version.
Uninstall the app from the app before deploying an updated version.
This is how to define permissions: https://flet.dev/docs/publish/android#permissions, https://flet.dev/docs/publish#cross-platform-permissions
[tool.flet.android.permission]
"android.permission.ACCESS_FINE_LOCATION" = true
"android.permission.ACCESS_COARSE_LOCATION" = true
I have to add the --android-permissions parameter to package it for it to work. If only the following method is used, it doesn't work. I don't know if it is a bug [tool.flet.android.permission] "android.permission.ACCESS_FINE_LOCATION" = true "android.permission.ACCESS_COARSE_LOCATION" = true
it should be [tool.flet.android.permissions] (s at the end)
I gave it a try and it works on my end:
Can you navigate to /build/flutter/android/app/src/main/AndroidManifest.xml and share the content here?
Use Geolocator classes from
flet_geolocatormodule, like in the example here: https://github.com/flet-dev/flet-geolocator?tab=readme-ov-file#example
pyproject.toml dependencies flet-geolocator==0.1.0
@FeodorFitsner also facing issue with flet-permission-handler and flet-one signal even added in dependencies