flutterlocation
flutterlocation copied to clipboard
Background geolocation has not worked since Android version 13
On versions 13 and 14, there is no notification about background geolocation. Everything works well on previous versions.
I also tested it after "flutter clean" and "flutter upgrade".
The following plugins are used in the project: cupertino_icons: ^1.0.2 go_router: ^12.0.0 shared_preferences: ^2.0.15 google_fonts: ^4.0.4 flutter_svg: ^2.0.7 accordion: ^2.6.0 signature: ^5.1.0 provider: ^6.0.5 http: ^1.1.0 intl: ^0.18.1 mime: ^1.0.4 http_parser: ^4.0.2 path_provider: ^2.1.1 mask_text_input_formatter: ^2.5.0 location: ^5.0.3
The project has the following permissions:
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>
kotlin_version: 1.9.21
dependencies: classpath 'com.android.tools.build:gradle:7.3.0'
flutter doctor: [√] Flutter (Channel stable, 3.13.6, on Microsoft Windows [Version 10.0.22621.3007], locale ru-RU) [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 34.0.0) [√] Chrome - develop for the web [√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.7.5) [√] Android Studio (version 2022.2) [√] VS Code (version unknown) X Unable to determine VS Code version. [√] Connected device (5 available) [√] Network resources
It does not produce any errors during testing.
For Android 13 I had to extend my permissions to get it run again. I use this:
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
I had the error below, which is now solved. Maybe it is the same cause?
Starting FGS with type location callerApp=ProcessRecord{XXX} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_LOCATION] any of the permissions allOf=false [android.permission.ACCESS_COARSE_LOCATION, android.permission.ACCESS_FINE_LOCATION] and the app must be in the eligible state/exemptions to access the foreground only permission
@crazyvonni @DiFo89 Any Solution on this?
Have you tried to extend the permissions?
For me everything is fine now.
Have you tried to extend the permissions?
For me everything is fine now.
No, I switched to another library because of the short deadlines.
@crazyvonni @DiFo89 Any Solution on this?
I've redone the logic using a different library (background_location)
I have the following error with API level 34:
Starting FGS with type location callerApp=ProcessRecord{58112eb 7114:cat.sol_it.letitbeat/u0a356} targetSDK=34 requires permissions: all of the permissions allOf=true [android.permission.FOREGROUND_SERVICE_LOCATION] any of the permissions allOf=false [android.permission.ACCESS_COARSE_LOCATION, android.permission.ACCESS_FINE_LOCATION] and the app must be in the eligible state/exemptions to access the foreground only permission
I solved it adding added permissos as @crazyvonni said.