2

I am trying to use FusedLocationProviderClient.getCurrentLocation().

It's supposed to be available according to the documentation here.

But in Android Studio, I am getting the error

Cannot resolve method 'getCurrentLocation' in 'FusedLocationProviderClient'

I know the recommended approach is to implement requestLocationUpdates(), but that's not what I am after here.

chongzixin
  • 1,951
  • 4
  • 28
  • 55

1 Answers1

11

You have to update to at least version 17.1.0 of the Google Play Location Services api. Include this line in your build.gradle (app):

implementation "com.google.android.gms:play-services-location:17.1.0"
Mario Huizinga
  • 780
  • 7
  • 14
  • 1
    omg this worked! how did you even know? i couldnt find it in the documentation. – chongzixin Oct 01 '20 at 13:34
  • 2
    See release notes for September 23, 2020: https://developers.google.com/android/guides/releases – Mario Huizinga Oct 01 '20 at 14:12
  • thanks Mario! Btw, classic Googlers. If I had a cent for each time their doc is incomplete, not up to date, or missing key informations, I would be a millionare lol. I swear 90% times their own code examples from docs do not work and I have to look elsewhere why it does not work...Almost every single time. – qkx Nov 29 '21 at 10:06
  • It works before I used ``` implementation 'com.google.android.gms:play-services-location:17.0.0' ``` – Vinayak Bansal Apr 11 '22 at 13:13