Skip to content
New issue

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

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

Already on GitHub? # to your account

bug: App crashes while geolocation is disabled and user grants permission #2186

Closed
1 of 4 tasks
ryandegruyter opened this issue Nov 17, 2019 · 6 comments · Fixed by #2409
Closed
1 of 4 tasks

bug: App crashes while geolocation is disabled and user grants permission #2186

ryandegruyter opened this issue Nov 17, 2019 · 6 comments · Fixed by #2409

Comments

@ryandegruyter
Copy link

ryandegruyter commented Nov 17, 2019

Bug 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) 

@FootDollarFiveLong
Copy link

Same error here on Android as well, can we get a resolution on this asap. My boss is gonna fire me if I don't fix it!

@ryandegruyter
Copy link
Author

@FootDollarFiveLong I resolved this at the moment by requesting GPS permission on startup, before the map screen is loaded.

@FootDollarFiveLong
Copy link

FootDollarFiveLong commented Dec 4, 2019

@FootDollarFiveLong I resolved this at the moment by requesting GPS permission on startup, before the map screen is loaded.

Our application requests permission before any use with google maps. As soon as permission is accepted, it crashes instantly, the map isn't used until well after. I will try and call it at the very beginning to see if it helps. Fingers crossed!

Edit: It did not work :(

@hellokingdom
Copy link

We are seeing the same in a PoC project we are working on. If location is disabled when the app is granted permission it crashes.

This does not appear to happen on Android 9 but does on Android 10.

@jcesarmobile
Copy link
Member

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 #379

@ionitron-bot
Copy link

ionitron-bot bot commented Nov 12, 2022

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.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Nov 12, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants