flutter-geolocator icon indicating copy to clipboard operation
flutter-geolocator copied to clipboard

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

Open bsv-anhvo opened this issue 1 year ago • 4 comments

Please check the following before submitting a new issue.

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
static Future<Position?> 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

Version

10.1.0

Flutter Doctor output

Doctor output
!] 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.

bsv-anhvo avatar Jun 07 '24 10:06 bsv-anhvo

Any update for this ? I have same crash in crashlytics

Screenshot 2024-07-13 at 08 10 24

Sergionius avatar Jul 13 '24 05:07 Sergionius

Any update on this?

iamnabink avatar Oct 01 '24 06:10 iamnabink

Any update on this?

martinsinn avatar Dec 02 '24 11:12 martinsinn

Any update on this?

Usman-Nazir avatar Mar 20 '25 16:03 Usman-Nazir