Search code examples
androidflutterlocation

Flutter app crash on precious location in Android


I have a flutter android app requesting location permission.

case 1) location permission is not given, the app opens normally and asks for location permission and everything works fine

case 2) approximate location permission is given, the app opens normally and everything works fine

case 3) (Problem) precious location permission is given, but the app does not open, it shows the white screen (android splash screen) for 10-20 sec and then crashes, with no proper error message

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.appName">

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.INTERNET" />

Manifest file

Geolocator Flutter lib

geolocator: ^9.0.2


Log message

  F/crash_dump64(15410): crash_dump.cpp:487] failed to attach to thread 669: Permission denied
  F/crash_dump64(15539): crash_dump.cpp:487] failed to attach to thread 744: Permission denied

Logcat message

2023-03-30 21:28:38.174 29257-29283/com.example.app_namek I/Quality: stackInfo :----- pid 29257 at 2023-03-30 21:28:38.150 -----;Cmd line: com.example.app_namek;"main" prio=5 tid=2 TIMED_WAITING sysTid=29257;  at jdk.internal.misc.Unsafe.park(Native Method);  at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:234);  at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedNanos(AbstractQueuedSynchronizer.java:1079);  at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireSharedNanos(AbstractQueuedSynchronizer.java:1369);  at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:278);  at com.google.android.gms.internal.location.zzau.getLastLocation(com.google.android.gms:play-services-location@@21.0.1:12);  at com.wongpiwat.trust_location.LocationAssistant.checkInitialLocation(LocationAssistant.java:494);  at com.wongpiwat.trust_location.LocationAssistant.access$600(LocationAssistant.java:57);  at com.wongpiwat.trust_location.LocationAssistant$8.onResult(LocationAssistant.java:730);  at com.wongpiwat.trust_location.LocationAssistant$8.onResult(LocationAssistant.java:722);  at com.google.android.gms.common.api.internal.BasePendingResult$CallbackHandler.handleMessage(com.google.android.gms:play-services-base@@18.1.0:6);  at android.os.Handler.dispatchMessage(Handler.java:106);  at android.os.Looper.loopOnce(Looper.java:233);  at android.os.Looper.loop(Looper.java:344);  at android.app.ActivityThread.main(ActivityThread.java:8212);  at java.lang.reflect.Method.invoke(Native Method);  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584);  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1034);
2023-03-30 21:28:39.684 29257-29283/com.example.app_namek I/Quality: stackInfo :----- pid 29257 at 2023-03-30 21:28:39.679 -----;Cmd line: com.example.app_namek;"main" prio=5 tid=2 TIMED_WAITING sysTid=29257;  at jdk.internal.misc.Unsafe.park(Native Method);  at java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:234);  at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedNanos(AbstractQueuedSynchronizer.java:1079);  at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireSharedNanos(AbstractQueuedSynchronizer.java:1369);  at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:278);  at com.google.android.gms.internal.location.zzau.getLastLocation(com.google.android.gms:play-services-location@@21.0.1:12);  at com.wongpiwat.trust_location.LocationAssistant.checkInitialLocation(LocationAssistant.java:494);  at com.wongpiwat.trust_location.LocationAssistant.access$600(LocationAssistant.java:57);  at com.wongpiwat.trust_location.LocationAssistant$8.onResult(LocationAssistant.java:730);  at com.wongpiwat.trust_location.LocationAssistant$8.onResult(LocationAssistant.java:722);  at com.google.android.gms.common.api.internal.BasePendingResult$CallbackHandler.handleMessage(com.google.android.gms:play-services-base@@18.1.0:6);  at android.os.Handler.dispatchMessage(Handler.java:106);  at android.os.Looper.loopOnce(Looper.java:233);  at android.os.Looper.loop(Looper.java:344);  at android.app.ActivityThread.main(ActivityThread.java:8212);  at java.lang.reflect.Method.invoke(Native Method);  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584);  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1034);
2023-03-30 21:28:48.004 29257-29269/com.example.app_namek I/app_name: Thread[6,tid=29269,WaitingInMainSignalCatcherLoop,Thread*=0xb4000071db901000,peer=0x136c0f38,"Signal Catcher"]: reacting to signal 3
2023-03-30 21:28:48.004 29257-29269/com.example.app_namek I/app_name:
2023-03-30 21:28:48.152 29257-29269/com.example.app_namek I/app_name: Wrote stack traces to tombstoned



Solution

  • As @Swanand mentioned in the comment.

    You can use

    dependency_overrides: geolocator_android: 4.1.4
    

    add this extra bit to your pubspec.yaml