Cannot Resolve Symbol: FusedLocationProviderClient.
Google play services version used 11.0.1.
code : while declaration
private FusedLocationProviderClient mfusedLocationProviderclient;
Cannot Resolve Symbol: FusedLocationProviderClient.
Google play services version used 11.0.1.
code : while declaration
private FusedLocationProviderClient mfusedLocationProviderclient;
You just need to include this in your build.gradle file:
implementation "com.google.android.gms:play-services-location:15.0.1"
or if you're not using latest gradle version:
compile "com.google.android.gms:play-services-location:15.0.1"
Note: It's recommended to use Google Play services version 15.0.1
or higher, which includes bug fixes for this class. More details here.
import com.google.android.gms.location.FusedLocationProviderClient;
to your Activity. –
Carvelbuilt In your build.gradle
(Module: app), you need to add the following dependency:
dependencies {
//...
compile 'com.google.android.gms:play-services:11.0.0'
}
and rebuild your app so it can download the needed dependencies. The class FusedLocationProviderClient
is included in this package.
Import following lines to the code after you have changed the build.gradle(Mudule:app)
including implementation:
"com.google.android.gms:play-services-location:11.0.1"
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationServices;
You just need to include this in your build.gradle file:
compile 'com.google.android.gms:play-services-location:12.0.1'
Code for retrieve Location :
FusedLocationProviderClient mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
mFusedLocationClient.getLastLocation()
.addOnSuccessListener(this, new OnSuccessListener<Location>() {
@Override
public void onSuccess(Location location) {
// Got last known location. In some rare situations this can be null.
}
})
.addOnFailureListener(this, new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
}
});
In build.gradle (Module: app) add:
dependencies {
...
implementation 'com.google.android.gms:play-services-location:17.0.0'
...
}
Don't forget to sync the build.gradle
(on the up right corner of the build.gradle
, you will have a notification to sync the changes, click it).
This Developer Guide solved my problem
In my case, I should include
com.google.android.gms:play-services-location:11.4.0
Not just play-services-maps:11.4.0.
Add COARSE_PERMISSION
in manifest.xml
file.
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
then it automatic detects the Class
and imports it.
I know it is very late, but happy to answer the question.
Use this dependencies
compile 'com.google.android.gms:play-services-location:11.0.4'
and refer this link - https://guides.codepath.com/android/Retrieving-Location-with-LocationServices-API
You just need to include this in your build.gradle file:
compile 'com.google.android.gms:play-services-location:11.0.2'
version of the services for location and maps should be the same.
compile 'com.google.android.gms:play-services-maps:11.0.2'
update your google play services to 11.8.0 The code that should be added to the bulild file is as follows
compile 'com.google.android.gms:play-services-gcm:11.8.0'
As everyone replied you need to put into your build.gradle file the line :
implement 'com.google.android.gms:play-services-location:11.0.1'
(substituting implement
for compile
depending on your gradle version)
The version just needs to be above 11.0.1, apparently.
However, when I did this I had a new error. Since I was already implementing the Play Service libraries (analytics, auth, maps, location) in a previous version (10.0.1) I had to change these all to the new version - you cant have only one of the libraries at a different version, need to have them all matching. So I found the implement lines with these libraries and changed them to:
implementation group: 'com.google.android.gms', name: 'play-services-analytics', version: '11.0.1'
implementation group: 'com.google.android.gms', name: 'play-services-auth', version: '11.0.1'
implementation group: 'com.google.android.gms', name: 'play-services-maps', version: '11.0.1'
implementation group: 'com.google.android.gms', name: 'play-services-location', version: '11.0.1'
Since I was also implementing firebase (not even sure what this is for and why it is related to Play Services), I had to the similar thing:
implementation group: 'com.google.firebase', name: 'firebase-core', version: '11.0.1'
implementation group: 'com.google.firebase', name: 'firebase-crash', version: '11.0.1'
Sync your project with gradle files and your FusedLocationProviderClient
should be visible/available, starting at the import:
import com.google.android.gms.location.FusedLocationProviderClient;
implementation(libs.play.services.location)
was added to gradle automatically
© 2022 - 2025 — McMap. All rights reserved.