Baseflow / Baseflow/flutter-geolocator

[Bug]: The connection to Google Play services was lost due to service disconnection

Open
#1,527 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
Dart
Stars
1.3k
Forks
803
Avg merge
8h 16m
Merged PRs (30d)
1

Description

### Please check the following before submitting a new issue.

- [X] I have searched the [existing issues](https://github.com/baseflow/flutter-geolocator/issues).
- [X] I have carefully [read the documentation](https://github.com/Baseflow/flutter-geolocator/blob/main/geolocator/README.md) and verified I have added the required platform specific configuration.

### Please select affected platform(s)

- [X] Android
- [ ] iOS
- [ ] Linux
- [ ] macOS
- [ ] Web
- [ ] Windows

### Steps to reproduce

When I call function Geolocator.isLocationServiceEnabled() and check log. Sometimes this error occur.

### Expected results

Why does this error occur? And I want to support to fix this error?
Thanks

### Actual results

Error occur in log

### Code sample

Code sample

```dart
static Future getMyLocation({required DataStoreApp dataStore}) async {
bool serviceEnabled;
LocationPermission permission;

// Test if location services are enabled
serviceEnabled = await Geolocator.isLocationServiceEnabled();
if (!serviceEnabled) {
'Location services are disabled.'.log();
return null;
}

// Check if the app has permission to access location
permission = await Geolocator.checkPermission();
if (permission == LocationPermission.denied) {
'Location permissions are denied'.log();
return null;
}

if (permission == LocationPermission.deniedForever) {
'Location permissions are permanently denied, we cannot request permissions.'.log();
return null;
}

return await Geolocator.getCurrentPosition().then((Position? position) {
'getCurrentPosition: success'.log();
return position;
}).onError((error, stackTrace) {
if(error is TimeoutException) {
return null;
}
});
}
```

### Screenshots or video

Screenshots or video demonstration

![Screenshot 2024-06-07 at 17 20 19](https://github.com/Baseflow/flutter-geolocator/assets/60602911/42b1d8b7-0999-477f-a3a0-27f41ab2ea58)

### Version

10.1.0

### Flutter Doctor output

Doctor output

```console
!] Flutter (Channel stable, 3.13.9, on macOS 14.0 23A344 darwin-x64, locale en-VN)
• Flutter version 3.13.9 on channel stable at /Users/anhvo/Documents/flutter_course/flutter_3.13.9-stable
! The flutter binary is not on your path. Consider adding /Users/anhvo/Documents/flutter_course/flutter_3.13.9-stable/bin to your path.
! The dart binary is not on your path. Consider adding /Users/anhvo/Documents/flutter_course/flutter_3.13.9-stable/bin to your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision d211f42860 (8 months ago), 2023-10-25 13:42:25 -0700
• Engine revision 0545f8705d
• Dart version 3.1.5
• DevTools version 2.25.0
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/anhvo/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• ANDROID_HOME = /Users/anhvo/Library/Android/sdk
• Java binary at: /Applications/Android Studio 2.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15A507
• CocoaPods version 1.13.0

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)

[✓] Android Studio (version 2023.1)
• Android Studio at /Applications/Android Studio 2.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)

[✓] IntelliJ IDEA Community Edition (version 2024.1)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] VS Code (version 1.84.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.76.0

[✓] Connected device (4 available)
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 12 (API 31) (emulator)
• Ip 88 (mobile) • 43784a242ea62d031ab4736267b32fdbaab1cdbe • ios • iOS 16.6.1 20G81
• macOS (desktop) • macos • darwin-x64 • macOS 14.0 23A344 darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 125.0.6422.142

[✓] Network resources
• All expected network resources are available.

! Doctor found issues in 1 category.
```

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the intermittent failure on Android while calling Geolocator.isLocationServiceEnabled(), using the reported Flutter 3.13.9, geolocator 10.1.0, and Android 12 environment where possible. Inspect the Android implementation and logs for the Google Play services disconnection; done means the cause is identified and a reproducible test or documented resolution exists.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, dart, flutter
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.