Description
Please check the following before submitting a new issue.
- I have searched the existing issues.
- I have carefully read the documentation and verified I have added the required platform specific configuration.
Please select affected platform(s)
- Android
- iOS
- Linux
- macOS
- Web
- Windows
Steps to reproduce
I'm unable to reproduce a disconnect locally, but we have thousands of crash reports with the stack trace captured in the actual results when we get disconnected from play services.
We're pretty sure that the bug is within FusedLocationClient.isLocationServiceEnabled. If the response is not successful, it calls listener.onLocationServiceError(), but doesn't exit, and all other paths from this point are attempting to return a second result which would also crash.
In our case, after returning an error via onLocationServiceError, the method calls response.getResult which throws an exception if the result was not successful as per docs. This exception is not caught and causes the thread to crash.
Interestingly, it's primarily Amazon fire devices (~90%) that get disconnected, but we do see Pixels and Galaxy phones along with some others.
Expected results
If we get disconnected from services, it should simply call result.error once and return.
Actual results
The thread crashes with:
Stack trace
Fatal Exception: com.google.android.gms.tasks.RuntimeExecutionException: com.google.android.gms.common.api.ApiException: 22: API failed to connect while resuming due to an unknown error.
at com.google.android.gms.tasks.zzw.getResult(com.google.android.gms:play-services-tasks@@18.0.2:3)
at com.baseflow.geolocator.location.FusedLocationClient.lambda$isLocationServiceEnabled$0(FusedLocationClient.java:142)
at com.google.android.gms.tasks.zzi.run(com.google.android.gms:play-services-tasks@@18.0.2:1)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:223)
at android.app.ActivityThread.main(ActivityThread.java:7719)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Caused by com.google.android.gms.common.api.ApiException: 22: API failed to connect while resuming due to an unknown error.
at com.google.android.gms.common.internal.ApiExceptionUtil.fromStatus(com.google.android.gms:play-services-base@@18.1.0:3)
at com.google.android.gms.common.api.internal.ApiExceptionMapper.getException(com.google.android.gms:play-services-base@@18.1.0:1)
at com.google.android.gms.common.api.internal.zag.zad(com.google.android.gms:play-services-base@@18.1.0:1)
at com.google.android.gms.common.api.internal.zabq.zaE(com.google.android.gms:play-services-base@@18.1.0:1)
at com.google.android.gms.common.api.internal.zabq.zaD(com.google.android.gms:play-services-base@@18.1.0:2)
at com.google.android.gms.common.api.internal.zabq.zaw(com.google.android.gms:play-services-base@@18.1.0:6)
at com.google.android.gms.common.api.internal.GoogleApiManager.handleMessage(com.google.android.gms:play-services-base@@18.1.0:47)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:223)
at android.os.HandlerThread.run(HandlerThread.java:67)
Code sample
Code sample
final isLocationServiceEnabled = await Geolocator.isLocationServiceEnabled();
Screenshots or video
Screenshots or video demonstration
[Upload media here]
Version
10.1.0
Flutter Doctor output
Doctor output
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.13.8, on Ubuntu 22.04.3 LTS 5.15.0-86-generic, locale en_CA.UTF-8)
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
✗ Android SDK file not found: /media/greg/sdks/android/platforms/android-34/android.jar.
[✓] Chrome - develop for the web
[✓] Linux toolchain - develop for Linux desktop
[✓] Android Studio (version 2022.3)
[✓] Android Studio (version 2022.2)
[✓] VS Code (version unknown)
✗ Unable to determine VS Code version.
[✓] Connected device (3 available)
[✓] Network resources
! Doctor found issues in 1 category.