-
Notifications
You must be signed in to change notification settings - Fork 1k
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
bug: Geolocation.getCurrentPosition() always returns "location unavailable" error message in Android simulator #2854
Comments
did you enable localization in the emulator? it's disabled by default |
@jcesarmobile where or how do I enable localization? If I open the built-in Google Maps app on the emulator it works just fine, so it seems like GPS is working at the emulator level, just not getting a location value from the Capacitor Geolocation plugin. |
I've been doing some tests and doesn't happen if you use I don't really know how the user can manually configure the location to use the network provider, I can't find the option on settings, but all my devices have them available. We could add the code to make the app show that prompt too, but it's very complex and this is not a common scenario, so not sure if it's worth it. For now I've added some code to check if the network provider is available and if not, use |
capacitor 的定位失败 不论使用何种方式 在android 都将显示未授权 |
Applied fix as outlined here: ionic-team/capacitor#2854 (comment)
Hello @jcesarmobile, I'm facing the same issue... I'm a newbie considering Android development thus i didn't really understand how you specified 'PRIORITY_LOW_POWER'. Is it in the vuejs code or somewhere in the Android project ? If you have some code example I would be glad to test it. Thanks you in advance for your response. |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out. |
Bug Report
Capacitor Version
npx cap doctor
output:💊 Capacitor Doctor 💊
Latest Dependencies:
@capacitor/cli: 2.0.2
@capacitor/core: 2.0.2
@capacitor/android: 2.0.2
@capacitor/electron: 2.0.2
@capacitor/ios: 2.0.2
Installed Dependencies:
@capacitor/electron not installed
@capacitor/cli 2.0.2
@capacitor/core 2.0.2
@capacitor/ios 2.0.2
@capacitor/android 2.0.2
[success] Android looking great! 👌
Found 4 Capacitor plugins for ios:
cordova-plugin-app-version (0.1.9)
cordova-plugin-ionic (5.4.6)
cordova-plugin-nativegeocoder (3.4.0)
cordova-plugin-whitelist (1.3.4)
[success] iOS looking great! 👌
Affected Platform(s)
Current Behavior
Calling
Geolocation.getCurrentPosition()
always returns the errorlocation unavailable
from inside the Android simulator (AVD) for Android API versions 29 and 28. iOS simulators are working fine.Expected Behavior
The current coordinates should be returned when in the Android simulator.
Sample Code or Sample Application Repo
Reproduction Steps
Other Technical Details
npm --version
output:6.14.4
node --version
output:v10.16.0
pod --version
output (iOS issues only):Other Information
Logcat error message:
D/Capacitor: Sending plugin error: {"save":false,"callbackId":"49816472","pluginId":"Geolocation","methodName":"getCurrentPosition","success":false,"error":{"message":"location unavailable"}}
I have the following already added in
AndroidManifest.xml
The text was updated successfully, but these errors were encountered: