bug: App crashes while geolocation is disabled and user grants permission
See original GitHub issueBug Report
Capacitor Version
npx cap doctor
output:
Latest Dependencies:
@capacitor/cli: 1.3.0
@capacitor/core: 1.3.0
@capacitor/android: 1.3.0
@capacitor/ios: 1.3.0
Installed Dependencies:
@capacitor/cli 1.3.0
@capacitor/core 1.3.0
@capacitor/ios 1.3.0
@capacitor/android 1.3.0
[success] Android looking great! 👌
Affected Platform(s)
- Android
- iOS
- Electron
- Web
Current Behavior
When device the GPS service is turned off And perrmissions are granted Then the application crashes
Expected Behavior
The application does not crash
Reproduction Steps
Call watchPosition or getCurrentPosition from the Geolocation plugin while the GPS service is turned off. After the user grants permission in the permission popup, the app will crash.
Other Information
Caused by: java.lang.IllegalArgumentException: invalid provider: null at android.location.LocationManager.checkProvider(LocationManager.java:2337) at android.location.LocationManager.requestLocationUpdates(LocationManager.java:553) at com.getcapacitor.plugin.Geolocation.startWatch(Geolocation.java:97) at com.getcapacitor.plugin.Geolocation.handleRequestPermissionsResult(Geolocation.java:190) at com.getcapacitor.Bridge.onRequestPermissionsResult(Bridge.java:746) at com.getcapacitor.BridgeActivity.onRequestPermissionsResult(BridgeActivity.java:201) at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:8264) at android.app.Activity.dispatchActivityResult(Activity.java:8114) at android.app.ActivityThread.deliverResults(ActivityThread.java:4838) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4886) at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7356) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:6 (1 by maintainers)
Top GitHub Comments
I could reproduce on Android 10, works fine on Android 9 as hellokingdom said.
In next major release we will move to fused location providers and will hopefully fix this problem https://github.com/ionic-team/capacitor/issues/379
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.