Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"getLocation()" never returns #172

Closed
shinayser opened this issue Apr 18, 2019 · 63 comments
Closed

"getLocation()" never returns #172

shinayser opened this issue Apr 18, 2019 · 63 comments

Comments

@shinayser
Copy link

shinayser commented Apr 18, 2019

(First of all, thanks for your hardwork at this library)

Describe the bug
I am calling this method before calling "runApp(MyApp())" in my main method. I need this because my app needs a current known location at its very first frame:

_getLastKnownLocation() async {
  print("STARTING LOCATION SERVICE");
  var location = Location();
  location.changeSettings(accuracy: LocationAccuracy.POWERSAVE);
  if (!await location.hasPermission()) {
    await location.requestPermission();
  } 

  InMemoryDatabase.lastKnownLocation = await location.getLocation();
}

The call gets stuck on the last line of this method, never returning a proper position.

I am using library version 2.3.5 with flutter 1.2.1

Expected behavior
The method should return a position.

Tested on:

  • Android, 8.1.0 Motorola Moto G5S (real device)
@giandifra
Copy link

i have same issue:

if i haven't enabled GPS when try to getLocation(), i confirm the request for enable it, but getLocation() never return, if i try again this work correctly

@Lyokone
Copy link
Owner

Lyokone commented Apr 19, 2019

Hey ! I'll look into this over the weekend. Don't hesitate to use the authorisation process from the sample app in the mean time :)

@Lyokone Lyokone added the bug label Apr 20, 2019
@hiddencaliber
Copy link

Hi @Lyokone ,

Thanks for this wonderful plugin.
I am also facing the same issue.

Please fix or suggest or suggest an alternate meanwhile.

Thanks,

@Lyokone
Copy link
Owner

Lyokone commented Apr 22, 2019

Hey ! Spent most of my time on the background location feature this weekend, so wasn't able to look into this. A simple workaround would be to use onLocationChanged() and to remove the listener once you get the first result.
Sorry for the delay in fixing this :/

@shinayser
Copy link
Author

Hey ! Spent most of my time on the background location feature this weekend, so wasn't able to look into this. A simple workaround would be to use onLocationChanged() and to remove the listener once you get the first result.
Sorry for the delay in fixing this :/

I've tested your sollution with await location.onLocationChanged().first and still blocking =(

@VinceERS
Copy link

VinceERS commented Apr 26, 2019

Thanks for the great work, unfortunately having the same problem.

I upgraded from v1.2.0 which worked fine to v2.3.5 recently and started having this problem. Tried each version between 2.0.0 and 2.3.5 and also tried location.onLocationChanged().first but always get the same problem. Also downgrading below v2.0.0 isn't possible for my app now as I am building for iOS and android and version constraints keep me from going back.

@Lyokone
Copy link
Owner

Lyokone commented Apr 26, 2019

Hey !

This is really strange since I'm having no problem on my end during testing and using the plugin in projects. Have you updated everything ? Can you launch adb logcat to see if you can get any other logs ?

@VinceERS
Copy link

VinceERS commented Apr 26, 2019

Thanks for any help you can provide, here's what I hope is near the beginning of the relevant logs using adb logcat from when I start using getLocation:

04-26 11:39:19.199 862 2259 I ActivityManager: START u0 {act=com.google.android.gms.location.settings.CHECK_SETTINGS pkg=com.google.android.gms cmp=com.google.android.gms/com.google.android.location.settings.LocationSettingsCheckerActivity (has extras)} from uid 10039
04-26 11:39:19.200 646 646 D QCOM PowerHAL: LAUNCH HINT: ON
04-26 11:39:19.203 646 646 D QCOM PowerHAL: Activity launch hint handled
04-26 11:39:19.210 9926 9926 W ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@1d982e6
04-26 11:39:19.275 492 526 D SurfaceFlinger: duplicate layer name: changing com.google.android.gms/com.google.android.location.settings.LocationSettingsCheckerActivity to com.google.android.gms/com.google.android.location.settings.LocationSettingsCheckerActivity#1
04-26 11:39:19.309 646 646 D QCOM PowerHAL: LAUNCH HINT: OFF
04-26 11:39:19.314 862 896 I ActivityManager: Displayed com.google.android.gms/com.google.android.location.settings.LocationSettingsCheckerActivity: +90ms
04-26 11:39:20.299 1510 1838 V ImsSenderRxr: Read packet: 22 bytes
04-26 11:39:20.299 1510 1510 D ImsServiceSub: Message received: what = 2
04-26 11:39:20.299 1510 1510 D ImsServiceSub: handleImsStateChanged
04-26 11:39:20.302 1510 1510 D ImsServiceSub: sendBroadcastForDisconnected
04-26 11:39:20.302 1510 1839 I MmTelFeatureCompat: registrationDisconnected: resetting MMTEL capabilities.
04-26 11:39:20.302 1510 1839 I MmTelFeatureConnection: onDeregistered ::
04-26 11:39:20.303 2069 2088 I MmTelFeatureConnection: onDeregistered ::
04-26 11:39:20.316 2069 12927 I rcs : [PresencePublication] mIsVolteAvailable=false mIsVoWifiAvailable=false mIsVtAvailable=false mIsViWifiAvailable=false oldIsVolteAvailable=false oldIsVoWifiAvailable=false oldIsVtAvailable=false oldIsViWifiAvailable=false
04-26 11:39:20.382 1510 1510 D ServiceStateProvider: subId=1
04-26 11:39:20.383 2744 2744 I CarrierServices: [2] cpo.onReceive: Received SERVICE_STATE intent, clearing cached cell info
04-26 11:39:21.899 629 629 D audio_hw_primary: disable_audio_route: usecase(1) reset and update mixer path: low-latency-playback speaker
04-26 11:39:21.904 629 629 D hardware_info: hw_info_append_hw_type : device_name = speaker
04-26 11:39:21.904 629 629 D audio_hw_primary: disable_snd_device: snd_device(2: speaker)
04-26 11:39:25.066 1963 1967 E ANDR-PERF-OPTSHANDLER: Warning: Resource [2, 0] not supported for core 1. Instead use resource for core 0
04-26 11:39:25.066 629 3817 I ACDB-LOADER: ACDB AFE returned = -19
04-26 11:39:25.066 1963 1967 E ANDR-PERF-RESOURCEQS: Failed to apply optimization [2, 2, 0]
04-26 11:39:25.067 629 3817 D hardware_info: hw_info_append_hw_type : device_name = speaker
04-26 11:39:25.067 629 3817 D audio_hw_primary: enable_snd_device: snd_device(2: speaker)
04-26 11:39:25.067 629 3817 D audio_route: Apply path: speaker
04-26 11:39:25.067 629 3817 D audio_hw_primary: enable_audio_route: usecase(1) apply and update mixer path: low-latency-playback speaker
04-26 11:39:25.067 629 3817 D audio_route: Apply path: low-latency-playback speaker
04-26 11:39:25.070 9926 9949 D OpenGLRenderer: endAllActiveAnimators on 0x74fddb8e00 (RippleDrawable) with handle 0x74fdb1b420
04-26 11:39:25.092 8429 8429 I GeofencerStateMachine: sendQueryLocationOptIn
04-26 11:39:25.100 629 3817 D audio_hw_primary: out_write: retry previous failed cal level set
04-26 11:39:25.110 862 862 V SettingsProvider: Notifying for 0: content://settings/secure/location_providers_allowed
04-26 11:39:25.116 8429 12935 W Bundle : Key source expected Integer but value was a bnta. The default value 0 was returned.
04-26 11:39:25.116 8429 12935 W Bundle : Attempt to cast generated internal exception:
04-26 11:39:25.116 8429 12935 W Bundle : java.lang.ClassCastException: bnta cannot be cast to java.lang.Integer
04-26 11:39:25.116 8429 12935 W Bundle : at android.os.BaseBundle.getInt(BaseBundle.java:1036)
04-26 11:39:25.116 8429 12935 W Bundle : at android.content.Intent.getIntExtra(Intent.java:7380)
04-26 11:39:25.116 8429 12935 W Bundle : at com.google.android.location.settings.AriLoggingIntentOperation.onHandleIntent(:com.google.android.gms@[email protected] (100400-244116403):2)
04-26 11:39:25.116 8429 12935 W Bundle : at com.google.android.chimera.IntentOperation.onHandleIntent(:com.google.android.gms@[email protected] (100400-244116403):2)
04-26 11:39:25.116 8429 12935 W Bundle : at pjz.onHandleIntent(:com.google.android.gms@[email protected] (100400-244116403):4)
04-26 11:39:25.116 8429 12935 W Bundle : at dwl.run(:com.google.android.gms@[email protected] (100400-244116403):12)
04-26 11:39:25.116 8429 12935 W Bundle : at dwi.run(:com.google.android.gms@[email protected] (100400-244116403):9)
04-26 11:39:25.116 8429 12935 W Bundle : at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
04-26 11:39:25.116 8429 12935 W Bundle : at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
04-26 11:39:25.116 8429 12935 W Bundle : at java.lang.Thread.run(Thread.java:764)
04-26 11:39:25.120 862 896 I GnssLocationProvider: WakeLock acquired by sendMessage(ENABLE, 1, null)
04-26 11:39:25.114 862 862 V SettingsProvider: Notifying for 0: content://settings/secure/location_providers_allowed
04-26 11:39:25.125 862 897 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.location.PROVIDERS_CHANGED flg=0x10 } to com.google.android.apps.maps/com.google.android.apps.gmm.locationsharing.usr.LocationAvailabilityChecker$LocationProvidersChangedBroadcastReceiver
04-26 11:39:25.126 862 897 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.location.PROVIDERS_CHANGED flg=0x10 } to com.google.android.gms/com.google.android.location.internal.NlpNetworkProviderSettingsUpdateReceiver
04-26 11:39:25.126 862 897 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.location.PROVIDERS_CHANGED flg=0x10 } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
04-26 11:39:25.126 862 897 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.location.PROVIDERS_CHANGED flg=0x10 } to com.google.android.googlequicksearchbox/com.google.android.apps.gsa.broadcastreceiver.external.ExternalCommonBroadcastReceiver
04-26 11:39:25.130 640 640 W GnssHAL_GnssInterface: setCallback called more than once. Unexpected unless test.
04-26 11:39:25.133 862 896 D GnssLocationProvider: gnssSetCapabilitesCb: 119u
04-26 11:39:25.134 862 897 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.location.MODE_CHANGED flg=0x10 } to com.google.android.apps.maps/com.google.android.apps.gmm.locationsharing.usr.LocationAvailabilityChecker$LocationProvidersChangedBroadcastReceiver
04-26 11:39:25.134 862 897 W BroadcastQueue: Background execution not allowed: receiving Intent { act=android.location.MODE_CHANGED flg=0x10 } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentTrustedReceiver
04-26 11:39:25.135 862 896 D GnssLocationProvider: gnssSetSystemInfoCb: yearOfHw=2016
04-26 11:39:25.135 640 640 E LocSvc_eng: loc_eng_init: log_eng state error: instance already initialized
04-26 11:39:25.135 640 640 E : open failed: /dev/mdm: No such file or directory
04-26 11:39:25.136 676 770 E PerMgrSrv: Permission denied, client UID 1021, peripehral modem
04-26 11:39:25.136 640 640 E PerMgrLib: modem registar fail
04-26 11:39:25.136 640 640 E PerMgrLib: GPS failed to register for modem
04-26 11:39:25.136 640 640 E LocSvc_LBSProxy: modemPowerVote:171]: Error: pm_client_register returned: -1
04-26 11:39:25.137 862 896 E GnssLocationProvider: Unable to initialize GNSS Xtra interface
04-26 11:39:25.137 640 640 E LocSvc_eng: loc_eng_agps_init: log_eng state error: agps instance already initialized
04-26 11:39:25.138 8429 8429 I GeofencerStateMachine: sendQueryLocationOptIn
04-26 11:39:25.140 8429 8597 I GeofencerStateMachine: Network location enabled.
04-26 11:39:25.142 862 862 V SettingsProvider: Notifying for 0: content://settings/global/network_recommendations_enabled
04-26 11:39:25.142 862 896 I GnssLocationProvider: WakeLock released by handleMessage(ENABLE, 1, null)
04-26 11:39:25.144 862 896 I GnssLocationProvider: WakeLock acquired by sendMessage(INJECT_NTP_TIME, 0, null)
04-26 11:39:25.144 862 896 I GnssLocationProvider: restartRequests
04-26 11:39:25.145 633 633 I NanohubHidlAdapter: Sending msg of type 0, size 18 to app 0x476f6f676c001004
04-26 11:39:25.147 8429 8429 I GeofencerStateMachine: sendQueryLocationOptIn
04-26 11:39:25.148 650 848 I nanohub : osLog: [NanoMinion] received MSG Type 0x31, Version 0, 14 bytes
04-26 11:39:25.150 862 896 I GnssLocationProvider: WakeLock released by handleMessage(INJECT_NTP_TIME, 0, null)
04-26 11:39:25.165 492 595 W SurfaceFlinger: Attempting to set client state on removed layer: com.google.android.gms/com.google.android.location.settings.LocationSettingsCheckerActivity#0
04-26 11:39:25.166 492 595 W SurfaceFlinger: Attempting to destroy on removed layer: com.google.android.gms/com.google.android.location.settings.LocationSettingsCheckerActivity#0
04-26 11:39:25.199 862 2244 W ActivityManager: Receiver with filter android.content.IntentFilter@878effa already registered for pid 12821, callerPackage is com.eventrentalsystems.www.erscontrolpanel
04-26 11:39:25.200 862 2189 W ActivityManager: Receiver with filter android.content.IntentFilter@9f889ab already registered for pid 12821, callerPackage is com.eventrentalsystems.www.erscontrolpanel
04-26 11:39:25.221 8429 8429 I NetRec : [2] aita.onChange: Starting service.
04-26 11:39:25.221 8429 8429 I NetRec : [2] aiwi.a: Now the active scorer.
04-26 11:39:25.222 8429 8593 W GCoreFlp: No location to return for getLastLocation()
04-26 11:39:25.250 8429 8605 W Settings: Setting airplane_mode_on has moved from android.provider.Settings.System to android.provider.Settings.Global, returning read-only value.
04-26 11:39:25.260 862 897 W BroadcastQueue: Background execution not allowed: receiving Intent { act=com.google.android.location.internal.server.ACTION_RESTARTED flg=0x10 } to com.google.android.gms/.chimera.GmsIntentOperationService$PersistentInternalReceiver
04-26 11:39:25.317 492 526 W SurfaceFlinger: Attempting to set client state on removed layer: com.google.android.gms/com.google.android.location.settings.LocationSettingsCheckerActivity#1
04-26 11:39:25.317 492 526 W SurfaceFlinger: Attempting to destroy on removed layer: com.google.android.gms/com.google.android.location.settings.LocationSettingsCheckerActivity#1
04-26 11:39:25.359 8429 8593 W GCoreFlp: No location to return for getLastLocation()
04-26 11:39:25.377 8429 8593 I chatty : uid=10039(com.google.android.gms) FlpThread identical 2 lines
04-26 11:39:25.393 8429 8593 W GCoreFlp: No location to return for getLastLocation()
04-26 11:39:25.405 8429 8444 I .gms.persisten: Background concurrent copying GC freed 149654(7MB) AllocSpace objects, 26(1496KB) LOS objects, 49% free, 7MB/15MB, paused 95us total 149.287ms
04-26 11:39:25.407 8429 8593 W GCoreFlp: No location to return for getLastLocation()
04-26 11:39:25.417 8429 12939 I GCoreUlr: Starting service, intent=Intent { act=com.google.android.location.reporting.ACTION_UPDATE_WORLD cmp=com.google.android.gms/com.google.android.location.reporting.service.DispatchingService (has extras) }, extras=Bundle[{receiverAction=android.location.PROVIDERS_CHANGED}]
04-26 11:39:25.422 8429 8429 W ChimeraUtils: Non Chimera context
04-26 11:39:25.422 8429 8429 I chatty : uid=10039 com.google.android.gms.persistent identical 2 lines
04-26 11:39:25.422 8429 8429 W ChimeraUtils: Non Chimera context
04-26 11:39:25.469 8429 12888 I GCoreUlr: WorldUpdater received intent Intent { act=com.google.android.location.reporting.ACTION_UPDATE_WORLD cmp=com.google.android.gms/com.google.android.location.reporting.service.DispatchingService (has extras) } with receiverAction android.location.PROVIDERS_CHANGED
04-26 11:39:25.483 8429 12888 I GCoreUlr: WorldUpdater:android.location.PROVIDERS_CHANGED: Ensuring that reporting is stopped because of reasons: {account#-5#=[InactiveReason{mIdentifier=6, mName='ReportingNotEnabled'}, InactiveReason{mIdentifier=14, mName='HistoryNotEnabled'}]}
04-26 11:39:25.492 8429 12888 I GCoreUlr: Unbound from all signal providers.
04-26 11:39:25.492 8429 12717 I GCoreUlr: Successfully accounts update
04-26 11:39:25.510 8429 12717 I GCoreUlr: DispatchingService ignoring Intent { act=android.net.wifi.WIFI_STATE_CHANGED flg=0x4000010 (has extras) } because ULR inactive
04-26 11:39:25.518 8429 12935 I GCoreUlr: Starting service, intent=Intent { act=com.google.android.location.reporting.ACTION_UPDATE_WORLD cmp=com.google.android.gms/com.google.android.location.reporting.service.DispatchingService (has extras) }, extras=Bundle[{receiverAction=com.google.android.location.internal.server.ACTION_RESTARTED}]
04-26 11:39:25.537 8429 8429 I GCoreUlr: Unbound from all signal providers.
04-26 11:39:25.537 8429 12717 I GCoreUlr: Successfully accounts update
04-26 11:39:25.538 8429 8429 I GCoreUlr: Stopping handler for UlrDispSvcFast
04-26 11:39:25.568 8429 8429 I BeaconBle: Using BLE 'L' hardware layer
04-26 11:39:25.570 8429 8429 W Nearby : Bind call too late - someone already tried to get: interface bpqz [CONTEXT service_id=49 ]
04-26 11:39:25.589 8429 12717 I GCoreUlr: WorldUpdater received intent Intent { act=com.google.android.location.reporting.ACTION_UPDATE_WORLD cmp=com.google.android.gms/com.google.android.location.reporting.service.DispatchingService (has extras) } with receiverAction com.google.android.location.internal.server.ACTION_RESTARTED
04-26 11:39:25.601 8429 12717 I GCoreUlr: WorldUpdater:com.google.android.location.internal.server.ACTION_RESTARTED: Ensuring that reporting is stopped because of reasons: {account#-5#=[InactiveReason{mIdentifier=6, mName='ReportingNotEnabled'}, InactiveReason{mIdentifier=14, mName='HistoryNotEnabled'}]}
04-26 11:39:25.609 8429 12717 I GCoreUlr: Unbound from all signal providers.
04-26 11:39:25.610 8429 12888 I GCoreUlr: Successfully accounts update
04-26 11:39:25.622 8429 12717 I GCoreUlr: DispatchingService ignoring Intent { act=android.net.wifi.WIFI_STATE_CHANGED flg=0x4000010 (has extras) } because ULR inactive
04-26 11:39:25.634 8429 8429 I GCoreUlr: Unbound from all signal providers.
04-26 11:39:25.635 8429 8429 I GCoreUlr: Stopping handler for UlrDispSvcFast
04-26 11:39:25.635 8429 12640 I GCoreUlr: Successfully accounts update
04-26 11:39:28.333 629 629 D audio_hw_primary: disable_audio_route: usecase(1) reset and update mixer path: low-latency-playback speaker
04-26 11:39:28.337 629 629 D hardware_info: hw_info_append_hw_type : device_name = speaker
04-26 11:39:28.338 629 629 D audio_hw_primary: disable_snd_device: snd_device(2: speaker)
04-26 11:39:31.341 642 642 I /vendor/bin/hw/[email protected]: SRAM data: 2812000

@veetaw
Copy link

veetaw commented Apr 28, 2019

Any news? I'm facing the same issue.

@Lyokone
Copy link
Owner

Lyokone commented Apr 28, 2019 via email

@veetaw
Copy link

veetaw commented Apr 28, 2019

I flashed a new custom ROM (Android Pie) on my phone, and now it works, and neither do I cannot reproduce the bug now. I'm going to try to reproduce it these days.

By the way, could it be a MIUI related issue?

@Lyokone
Copy link
Owner

Lyokone commented Apr 28, 2019 via email

@giandifra
Copy link

@Lyokone I use PIXEL 2 XL with original OS

@shinayser
Copy link
Author

I am using stock Xiami Mi A2 and stock Motorola Moto G5S.

@VinceERS
Copy link

I'm also using stock on the pixel 1, Android 9.

@Lyokone
Copy link
Owner

Lyokone commented Apr 29, 2019

So a lot of different devices, Pixels especially should be fine. Is the sample app working properly for you ? Maybe the plugin isn't returning a proper error of something you would be missing.

@AlecsFerra
Copy link

Same issue on meizu M5 note w/ stock rom on the latest update

@sarimk80
Copy link

sarimk80 commented May 4, 2019

The app is not crashing but it is giving null on getLocation()
i tried it in galaxy j5

`LocationData _currentLocation;

Location _location;

Future getLoc() async {
_currentLocation = await _location.getLocation();

try {
  return _currentLocation.longitude;
} catch (e) {
  print("Error");
}
return 0.0;

}`

gradle.properties

android.enableJetifier=true android.useAndroidX=true org.gradle.jvmargs=-Xmx1536M

gradle.build
dependencies { classpath 'com.android.tools.build:gradle:3.2.1' classpath 'com.google.gms:google-services:4.2.0' }

E/flutter (26075): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: NoSuchMethodError: The method 'getLocation' was called on null.
E/flutter (26075): Receiver: null
E/flutter (26075): Tried calling: getLocation()
E/flutter (26075): #0 Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:50:5)
E/flutter (26075): #1 _NamazState.getLoc (package:flutter_quran/src/namaz_timing/NamazPage.dart:19:40)
E/flutter (26075):
E/flutter (26075): #2 _NamazState.initState (package:flutter_quran/src/namaz_timing/NamazPage.dart:33:5)
E/flutter (26075): #3 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3846:58)
E/flutter (26075): #4 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3711:5)
E/flutter (26075): #5 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2956:14)
E/flutter (26075): #6 Element.updateChild (package:flutter/src/widgets/framework.dart:2759:12)
E/flutter (26075): #7 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4876:14)
E/flutter (26075): #8 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2956:14)
E/flutter (26075): #9 Element.updateChild (package:flutter/src/widgets/framework.dart:2759:12)
E/flutter (26075): #10 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
E/flutter (26075): #11 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
E/flutter (26075): #12 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3716:5)
E/flutter (26075): #13 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3711:5)
E/flutter (26075): #14 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2956:14)
E/flutter (26075): #15 Element.updateChild (package:flutter/src/widgets/framework.dart:2759:12)
E/flutter (26075): #16 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4876:14)
E/flutter (26075): #17 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2956:14)
E/flutter (26075): #18 Element.updateChild (package:flutter/src/widgets/framework.dart:2759:12)
E/flutter (26075): #19 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4876:14)
E/flutter (26075): #20 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2956:14)
E/flutter (26075): #21 Element.updateChild (package:flutter/src/widgets/framework.dart:2759:12)
E/flutter (26075): #22 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4876:14)
E/flutter (26075): #23 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2956:14)
E/flutter (26075): #24 Element.updateChild (package:flutter/src/widgets/framework.dart:2759:12)
E/flutter (26075): #25 SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4876:14)
E/flutter (26075): #26 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2956:14)
E/flutter (26075): #27 Element.updateChild (package:flutter/src/widgets/framework.dart:2759:12)
E/flutter (26075): #28 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
E/flutter (26075): #29 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
E/flutter (26075): #30 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3716:5)
E/flutter (26075): #31 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3864:11)
E/flutter (26075): #32 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3711:5)
E/flutter (26075): #33 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2956:14)
E/flutter (26075): #34 Element.updateChild (package:flutter/src/widgets/framework.dart:2759:12)
E/flutter (26075): #35 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
E/flutter (26075): #36 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
E/flutter (26075): #37 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3716:5)
E/flutter (26075): #38 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3711:5)
E/flutter (26075): #39 Element.inflateWidget (package:flutter/src/widgets/framework.dart:2956:14)
E/flutter (26075): #40 Element.updateChild (package:flutter/src/widgets/framework.dart:2759:12)
E/flutter (26075): #41 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3747:16)
E/flutter (26075): #42 Element.rebuild (package:flutter/src/widgets/framework.dart:3559:5)
E/flutter (26075): #43 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3716:5)
E/flutter (26075): #44 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3864:11)
E/flutter (26075): #45 Compone

@veetaw
Copy link

veetaw commented May 4, 2019

@sarimk80 Location _location = Location()

@VinceERS
Copy link

VinceERS commented May 7, 2019

Just to give another update on this issue, I took care of the problems by handling permissions another way before calling _location.getLocation();

Seems like the problem I was having was about handling permissions properly? Sorry I have not ran into the problem in the example app, as far as I can recall it worked fine.

@NilsBacke
Copy link

I am also having this issue. Requesting permissions first, then on confirm of permissions, calling getLocation()

@pedromassango
Copy link

I'm having the same issue here. When I call _location= await Location().getLocation(); it show me a dialog about enabling the device location and it enable the location, but the function never return.

@sarimk80
Copy link

sarimk80 commented May 13, 2019

Call the future method in future builder this method work for me

` LocationData _currentLocation;

Location _location = Location();

Future getLoc() async {
_currentLocation = await _location.getLocation();

try {
  final coordinates = new Coordinates(
      _currentLocation.latitude, _currentLocation.longitude);
  var addresses =
      await Geocoder.local.findAddressesFromCoordinates(coordinates);
  var first = addresses.first;
  return first.locality;
} catch (e) { 
}
return "Earth";

}`

Try calling future with Future Builder

`body: FutureBuilder(

        future: getLoc(),

        builder: (BuildContext context, AsyncSnapshot snapshot_loc) {

          print(snapshot_loc.data);
          if (!snapshot_loc.hasData) {
            return Center(
              child: CircularProgressIndicator(),
            );
          } else {
         print(snapshot_loc.data)

        }`

@pedromassango
Copy link

I need to load my data out of a widget. I've tried to load using Future but it ins't work.

@gerryhigh
Copy link

I figured out why it was not working for me. requestPermission was not getting called. After debugging it I found another plugin (device_calendar) was blindly returning true in their permissions handler even though it was for a different permission. Thus flutter was not calling the handler for location.

Here is a link to the related issue: builttoroam/device_calendar#79

@Lyokone
Copy link
Owner

Lyokone commented May 14, 2019

I figured out why it was not working for me. requestPermission was not getting called. After debugging it I found another plugin (device_calendar) was blindly returning true in their permissions handler even though it was for a different permission. Thus flutter was not calling the handler for location.

Here is a link to the related issue: builttoroam/flutter_plugins#79

Hey ! Thanks for finding that, I'll see if I can better isolate my requests to not get handled by other plugins methods !
Was wondering what It could be for quite some time now :/

@uzairamer
Copy link

I figured out why it was not working for me. requestPermission was not getting called. After debugging it I found another plugin (device_calendar) was blindly returning true in their permissions handler even though it was for a different permission. Thus flutter was not calling the handler for location.
Here is a link to the related issue: builttoroam/flutter_plugins#79

Hey ! Thanks for finding that, I'll see if I can better isolate my requests to not get handled by other plugins methods !
Was wondering what It could be for quite some time now :/

Really looking forward.

@pedromassango
Copy link

pedromassango commented May 15, 2019

I figured out why it was not working for me. requestPermission was not getting called. After debugging it I found another plugin (device_calendar) was blindly returning true in their permissions handler even though it was for a different permission. Thus flutter was not calling the handler for location.
Here is a link to the related issue: builttoroam/flutter_plugins#79

Hey ! Thanks for finding that, I'll see if I can better isolate my requests to not get handled by other plugins methods !
Was wondering what It could be for quite some time now :/

Yhea it seems to be a builttoroam's package issue, can someone please fix it?

@rirjkl19
Copy link

rirjkl19 commented Aug 6, 2019

@Banglemoose Using LocationAccuracy.LOW for me is a no. It forces me to open my wifi even if I am not connected to any network. Is there anyway to prevent it from asking for wifi accessibility?

@HenriqueWojcik
Copy link

Is there a solution ? version 2.3.5 continues with same problem

@Marsiecom
Copy link

Hello , any news? we are also looking for a solution we want to make a routing app but we can not track our location

@Fabi755
Copy link

Fabi755 commented Sep 25, 2019

It seems that the repository is no longer maintained. I now use flutter-geolocator and it works fine.

@stale
Copy link

stale bot commented Oct 25, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the inactive label Oct 25, 2019
@awhitford
Copy link

Sounds related to #239.

@stale stale bot removed the inactive label Oct 30, 2019
@stale
Copy link

stale bot commented Nov 29, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the inactive label Nov 29, 2019
@stale stale bot closed this as completed Dec 6, 2019
@ollyde
Copy link

ollyde commented Mar 29, 2020

I'm seeing this issue on iOS now.

@sam-parks
Copy link

I'm seeing this on IOS as well.

@isc-hemc
Copy link

isc-hemc commented Apr 19, 2020

Same problem here in iOS and changing the accuracy to low doesn't work for me

@pedromassango
Copy link

For those who still having this issue I'm using this workaround:

  1. Use another package to check and ask for permission
  2. If permission granted then use this package

This works and is what I'm currently using in prodution. Let me know if this helps you in any way.

@ollyde
Copy link

ollyde commented Apr 20, 2020

@pedromassango also have this solution in place for several Flutter apps but it's extremely poor. Seeing the issue on our iOS apps for Reach-Native.

@pedromassango
Copy link

@Lyokone do you have plans to use another package for permission requests?

@OrionWambert
Copy link

Still the same issue I think I will use flutter-geolocator https://pub.dev/packages/geolocator

@junaidlodhi22
Copy link

same issue

@aquilarafa
Copy link

Same issue with me in macos app.

Solved by enabling WIFI connection in mac settings.
They say macos and iphone needs to get location data from wifi local networks
Related: https://www.youtube.com/watch?v=hY_z1_0RUSM

Flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel unknown, 2.2.0, on macOS 11.4 20F71 darwin-arm, locale pt-BR)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.57.1)
[✓] Connected device (2 available)

@cjdiez
Copy link

cjdiez commented Jan 5, 2023

location.changeSettings(accuracy: LocationAccuracy.low) worked for me #172 (comment)

@pedromassango
Copy link

location.changeSettings(accuracy: LocationAccuracy.low) worked for me #172 (comment)

This is not a solution if you need a high accuracy location data.

@LenvZyl
Copy link

LenvZyl commented Jan 20, 2023

Still an issue tried location.changeSettings(accuracy: LocationAccuracy.low) but issue remains
iOS mainly

@imsamgarg
Copy link

imsamgarg commented May 8, 2023

Still getting the same issue even after this workaround.. (Tried in both miui & lineage)

For those who still having this issue I'm using this workaround:

1. Use another package to check and ask for permission

2. If permission granted then use this package

This works and is what I'm currently using in prodution. Let me know if this helps you in any way.

@gabrielfulltime
Copy link

The problem was occurring here always after than I ask to enable location service.

To resolve it, I put an await Future.delayed(Duration(seconds: 1)) before of getLocation() and it works for me.

@hsynksahin
Copy link

hsynksahin commented Dec 12, 2023

The same problem still occurs, even tho I put a delay between requestPermission and getLocation.

I was using an other package to request permission from user, but for better compatibility (with IOS) I switched to use in-package permission request. When ever I request permission then wait for a location event (or just use getLocation) there wont be any event occurs.

The problem occurs both Android Emulator & IOS Simulator devices, and as I remember even with the other package to get permissions and a physical device and the release build, the first request always takes some time. But this time I wait for way too long that nothing happen.

I guess even tho the permission_handler package is hard to integrate, gotta use that package for requesting the permission.

FIX: now I switched to permission_handler back again its still not working on both IOS and Android

@Lyokone any suggestions ?

@MS-Rex
Copy link

MS-Rex commented Jul 31, 2024

Hey everyone!
Just wanted to share a workaround I found for this issue. It seems that adding a slight delay before calling getLocation() can help resolve this problem in some cases.

Here's a snippet of how I implemented it:

Future<LocationData?> getLocation() async {
    final serviceEnabled = await isServiceEnabled();
    final permissionGranted = await requestPermission();
    if (permissionGranted && serviceEnabled) {
      try {
        //INFO : this line is needed and it is a workaround for the issue in the location package
        await Future.delayed(const Duration(seconds: 1));
        return location.getLocation();
      } catch (e) {
        return null;
      }
    } else if (!serviceEnabled) {
      await AppSettings.openAppSettings(type: AppSettingsType.location);
    } else {
      await AppSettings.openAppSettings();
    }
    return null;
  }

It's not a perfect solution, but it might be a helpful bandaid for folks who are stuck. Hopefully, this issue can be resolved soon with a more permanent fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests