Cannot Resolve Symbol: FusedLocationProviderClient. Google play services version used 11.0.1
Asked Answered
W

13

88

Cannot Resolve Symbol: FusedLocationProviderClient.

Google play services version used 11.0.1.

code : while declaration

private FusedLocationProviderClient mfusedLocationProviderclient;
Weihs answered 20/6, 2017 at 11:31 Comment(4)
Welcome to StackOverflow! In order to help others understand your issue, please post a sample of code, the outputs of any logs (e.g. LogCat) or something to demonstrate a minimal, complete, and verifiable example of your problem.Hadst
Typically your posts on a Q&A site should include an actual question. Adding code helps too. Like your Gradle filesBogbean
If it can't resolve in the field, then you did not import the class.Bogbean
I did and the issue is resolved. This location services update is available in the latest android studio version(2.3.3)Weihs
L
146

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.

https://developers.google.com/android/reference/com/google/android/gms/location/FusedLocationProviderClient

Longterm answered 29/6, 2017 at 15:37 Comment(2)
You also need to add the line import com.google.android.gms.location.FusedLocationProviderClient; to your Activity.Carvelbuilt
to get the latest version of the dependency: developers.google.com/android/guides/setupNeuter
G
11

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.

Giarla answered 22/6, 2017 at 22:5 Comment(2)
It's not working for me. What all other features be there to resolve this?Combings
Look answer below and read the docs, use specific library you need so you don't bloat your app with stuff you don't use.Aeroballistics
D
9

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;
Diametrically answered 26/1, 2018 at 5:49 Comment(1)
Could you please highlight what is code and what not with the provided tool of SO-editor!Commuter
B
6

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) {

                        }
                    });
Bookbindery answered 21/5, 2018 at 8:35 Comment(0)
M
6

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).

Microseism answered 31/5, 2020 at 5:47 Comment(0)
G
5

This Developer Guide solved my problem

Gush answered 23/6, 2017 at 6:58 Comment(1)
I wonder why the docs don't point us to the right place to get the required dependencies.Suborn
R
3

In my case, I should include

com.google.android.gms:play-services-location:11.4.0  

Not just play-services-maps:11.4.0.

Raybourne answered 17/1, 2018 at 17:49 Comment(0)
T
2

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.

Tunicle answered 17/5, 2018 at 9:4 Comment(0)
H
1

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

Humidify answered 10/10, 2017 at 8:15 Comment(0)
G
0

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'

Grimsby answered 15/7, 2017 at 16:45 Comment(0)
A
0

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'

Arnold answered 13/3, 2018 at 11:39 Comment(0)
C
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;
Capitalism answered 13/2, 2020 at 16:1 Comment(0)
P
0

implementation(libs.play.services.location)

was added to gradle automatically

Penetrance answered 29/4, 2024 at 18:47 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.