Create LocationRequest for API lower than 31

790 Views Asked by At

I have compileSdkVersion 32 and now I can create LocationRequest only using LocationRequest.Builder. LocationRequest.create() currently unavailable, means I can't even call this deprecated static method. So any suggestions how to create LocationRequest for API lower than 31? Thanks.

3

There are 3 best solutions below

0
Konstantin Konopko On BEST ANSWER

Solved with using com.google.android.gms.location.LocationRequest

0
CommonsWare On

You cannot create a LocationRequest on API Level 30 and below, because LocationRequest itself was added in API Level 31.

You should be able to use LocationRequestCompat as a backwards-compatible replacement, used with LocationManagerCompat.

0
Anish Vahora On

Update location service library to the late version and use correct import, for me the latest version right now is

implementation 'com.google.android.gms:play-services-location:21.0.1'

this version may have been changed when you will be seeing this answer, so make sure to update to the latest version.