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 could you provide a little bit more information?
Meanly I would be interested in the platform you are on.
@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)
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?
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
Here is the screenshot for calling method getCurrentPosition
At 2020-02-03 16:31:52, "Maurits van Beusekom" notifications@github.com wrote:
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?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
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)
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.
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.
The same thing there is no response
void getLocation() async {
Position position = await Geolocator()
.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
print(position);
}
I was able to fix the issue by adding
>
NSLocationAlwaysUsageDescription
This app needs access to location when in the background.
NSLocationAlwaysAndWhenInUseUsageDescription
This app needs access to location when open and in the background.
to my Info.plist file. You guys should check if the above codes are added.
On Wed, Mar 25, 2020 at 8:02 AM Valeh ASADLI notifications@github.com
wrote:
The same thing there is no response
void getLocation() async { Position position = await Geolocator()
.getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
print(position); }—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/Baseflow/flutter-geolocator/issues/386#issuecomment-603890873,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AELYL4FI4EEHNNJ6ZP2WMNDRJIMIDANCNFSM4KPA5CPQ
.
using ACCESS_FINE_LOCATION instead of ACCESS_COARSE_LOCATION can resolve my error on android (using simulator).
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:-
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)
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
Position position = await Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.high);
print(position);
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
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.
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).
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.
@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.
Most helpful comment
Same problem here. The call to
getCurrentPositionhangs 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
desiredAccuracydidn't seem to work either.