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

No location information available,can not get the location #386

Closed
chao9267 opened this issue Feb 3, 2020 · 17 comments
Closed

No location information available,can not get the location #386

chao9267 opened this issue Feb 3, 2020 · 17 comments
Labels
platform: android Issue is related to the Android platform.
Milestone

Comments

@chao9267
Copy link

chao9267 commented Feb 3, 2020

geolocator: ^5.2.1

I have obtained location permissions,but calling the mehtod
await Geolocator().getLastKnownPosition(desiredAccuracy: LocationAccuracy.high).then((location){print('$location');});
the location is null;
and calling the mehtod
await Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.high).then((location){print('$location');});
there is no response for location。

@chao9267 chao9267 changed the title No location information available No location information available,can not get the location Feb 3, 2020
@mvanbeusekom
Copy link
Member

@chao9267 could you provide a little bit more information?

Meanly I would be interested in the platform you are on.

@chao9267
Copy link
Author

chao9267 commented Feb 3, 2020

@mvanbeusekom flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.9.1+hotfix.6, on Microsoft Windows [Version 6.1.7601], locale zh-CN)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[√] Android Studio (version 3.5)
[√] Connected device (1 available)

@mvanbeusekom
Copy link
Member

Are you testing with Android on the simulator or on a real device?

Are the location services turned on? if on the simulator are you actually simulating GPS coordinates?

@chao9267
Copy link
Author

chao9267 commented Feb 3, 2020

I used the 5.1.5 version was normal before, but now it is invalid. It is the same when I switch to the 5.2.1 version. I use the real android phone test,and my app locaiton permission turned on in system setting

@chao9267
Copy link
Author

chao9267 commented Feb 3, 2020 via email

@scortumee
Copy link

scortumee commented Feb 7, 2020

I am having a same problem, too. Version 5.1.5 was working fine on my phone. I just upgraded to v5.2.1. Still the same problem (no response from getCurrentPosition)
My specs:
[✓] Flutter (Channel unknown, v1.12.13+hotfix.4, on Mac OS X 10.14.6 18G95,
locale en-US)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[✓] Android Studio (version 3.3)
[✓] Connected device (1 available)

Physical device: iphone 8 (13.3.1)

@maganap
Copy link

maganap commented Feb 15, 2020

Same problem here. The call to getCurrentPosition hangs forever. It happens whether permissions were already granted or not. If the permission dialog shows up, no matter what the user replies, the call never returns either.

On Android: Something weird is that it did seem to work well the first couple of times. I denied permissions from system settings to keep testing. Then, it never worked again. I rebooted the device, the problem persisted.

Then I switched to iOS device, and the problem showed up from the very first test.

Tried with geolocator 5.2.1 and 5.1.5.
Flutter (Channel master, v1.15.4-pre.82, on Mac OS X 10.15.2 19C57, locale en-ES)
Physical devices: Huawei P8 (Android 6.0), iPhone X (iOS 13.3.1)

I guess it's related to #393 and #375, although in my case changing desiredAccuracy didn't seem to work either.

@kwent
Copy link

kwent commented Feb 17, 2020

Seeing same issue with

geolocate 5.2.1

[✓] Flutter (Channel stable, v1.12.13+hotfix.8, on Mac OS X 10.15.2 19C57, locale en-US)

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.41.1)
[✓] Connected device (2 available)

In my case only reproducible on real android device. getCurrentPosition is hanging indefinitely. Changing desiredAccuracy do not fix it.

No issue on ios for my case.

@valehasadli
Copy link

The same thing there is no response

void getLocation() async { Position position = await Geolocator() .getCurrentPosition(desiredAccuracy: LocationAccuracy.high); print(position); }

@scortumee
Copy link

scortumee commented Mar 26, 2020 via email

@Anima7
Copy link

Anima7 commented Apr 12, 2020

using ACCESS_FINE_LOCATION instead of ACCESS_COARSE_LOCATION can resolve my error on android (using simulator).

@sherrychhabra51
Copy link

sherrychhabra51 commented Apr 14, 2020

I am using Pixel 2 having Android 10 version to test this feature of getting current location, but i am not able to fetch the location .The issue that i am facing is that location icon is not getting turned on automatically after providing location permission. User has to tap on the location icon manually in order to provide his location which is not the expected behavior.

Following are the steps that are getting performed after app installation:-

  1. Click on Button to get current location and a dialog pops up with 3 options (Allow all the time, Allow while using the app and Deny & dont ask again)

  2. Click on Allow all the time or Allow while using the app option from the dialog, it should ideally turn on the location icon but what i can see is that after providing the permission, Location permission is there in App's Permission section but the icon of Location is still turned off which should be automatically turned on as soon as user is providing the permission .

I am currently using Flutter 1.18.0 • channel dev

Geolocator plugin version :-
geolocator: ^5.3.1

Code:-

Position position = await Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
    print(position);

@ifin2000
Copy link

ifin2000 commented Apr 21, 2020

I have same issue when run at android 9 device (in debug mode), at emulator running perfect.
this is my code :

getCurrentLocation() async { final Geolocator geolocator = Geolocator()..forceAndroidLocationManager; await geolocator .getCurrentPosition(desiredAccuracy: LocationAccuracy.high) .then((Position position) { setState(() { _currentPosition = position; }); }).catchError((e) { print(e); }); }

no error displayed..

I am currently using Flutter 1.18.0-6.0.pre64
Geolocator plugin version : geolocator: ^5.3.1

@mvanbeusekom mvanbeusekom added the platform: android Issue is related to the Android platform. label May 8, 2020
@mvanbeusekom
Copy link
Member

After debugging this issue I think it might be related to the new version of the location_permissions plugin. This plugin requires your project to be updated to the Flutter 1.12.* Android project structure.

You can do so using these instructions also have a look at issue #408.

Please let me know if this solves the issue.

@mvanbeusekom mvanbeusekom added the status: needs more info We need more information before we can continue work on this issue. label May 8, 2020
@mvanbeusekom
Copy link
Member

This issue should be solved in version 6.0.0-rc.x. I will be promoting this to stable soon.

Also make sure on Android you add the ACCESS_FINE_LOCATION permission to your AndroidManifest.xml (using the ACCESS_COARSE_LOCATION is indeed returning locations with a lot of delay). More information about adding the permissions can be found here (under the Android section).

@mvanbeusekom mvanbeusekom added this to the 6.0.0 milestone Aug 27, 2020
@mvanbeusekom mvanbeusekom removed the status: needs more info We need more information before we can continue work on this issue. label Aug 27, 2020
@matthewlloyd
Copy link

It might be worth mentioning in the README.md that using ACCESS_COARSE_LOCATION causes location update delays. In particular, on the emulator it seems to result in delays longer than a few minutes in receiving the initial position (it could be the position is never received, but I only waited a few minutes to see). This is because ACCESS_COARSE_LOCATION gives the app access only to network location providers, not GPS. I ran into this issue with 6.0.0-rc.4 and figured it was a bug, but after some debugging I realized I just needed to add ACCESS_FINE_LOCATION. The docs currently state that coarse location works, just at roughly the city-block level.

@mvanbeusekom
Copy link
Member

@matthewlloyd thank you for the suggestion. This morning I release the final 6.0.0 version of the geolocator and made sure I updated the documentation to explain about the ACCESS_COARSE_LOCATION permission.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform: android Issue is related to the Android platform.
Projects
None yet
Development

No branches or pull requests

10 participants