Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LocationRequest and LocationServices.API are not resolved

I have a high priority project under development.
I am trying to insert geo location into db so I found a service online and unfortunately LocationRequest and LocationServices.API are not resolved.
I am using the dependency 'com.google.android.gms:play-services-maps:10.2.0'

enter image description here

I tried adding the imports

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;

You can find the code I used at this link

like image 624
Krishna Avadhanam Avatar asked Mar 09 '17 06:03

Krishna Avadhanam


People also ask

What is LocationRequest in android?

public final class LocationRequest extends Object. implements Parcelable. An encapsulation of various parameters for requesting location through FusedLocationProviderClient .

What is fused location provider API?

The fused location provider is a location API in Google Play services that intelligently combines different signals to provide the location information that your app needs.

What is the use of FusedLocationProviderClient?

FusedLocationProviderClient is for interacting with the location using fused location provider.

What is package used for accessing location in mobile app?

The Google Location Services API, part of Google Play services, is the preferred way to add location-awareness to your app. It offers a simpler API, higher accuracy, low-power geofencing, and more.


2 Answers

Seems like you need to compile the play-services-location package.

Put these into the build.gradle

ext {
    playServicesVersion = '10.2.0' // update accordingly 
}

dependencies {
    ...
    compile "com.google.android.gms:play-services-maps:${playServicesVersion}"
    compile "com.google.android.gms:play-services-location:${playServicesVersion}"
}
like image 145
OneCricketeer Avatar answered Nov 03 '22 00:11

OneCricketeer


Try this implementation 'com.google.android.gms:play-services-location:15.0.1' in your app.gradle, and update the version regularly.

like image 36
Jiraiya Avatar answered Nov 03 '22 01:11

Jiraiya