Cannot Resolve Symbol: FusedLocationProviderClient. Google play services version used 11.0.1
AndroidGoogle Play-ServicesAndroid Problem Overview
> Cannot Resolve Symbol: FusedLocationProviderClient.
Google play services version used 11.0.1.
code : while declaration
private FusedLocationProviderClient mfusedLocationProviderclient;
Android Solutions
Solution 1 - Android
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.
Solution 2 - Android
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.
Solution 3 - Android
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;
Solution 4 - Android
This Developer Guide solved my problem
Solution 5 - Android
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) {
}
});
Solution 6 - Android
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).
Solution 7 - Android
In my case, I should include
com.google.android.gms:play-services-location:11.4.0
Not just play-services-maps:11.4.0.
Solution 8 - Android
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.
Solution 9 - Android
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
Solution 10 - Android
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'
Solution 11 - Android
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'
Solution 12 - Android
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;