Can't Import

I'm trying to get the most accurate location.

till now I'v used successfully LocationClient as in Google docs:

But now I have discovered that this class is old:

"This class is deprecated. Use LocationServices".

However in the examples of LocationServices even in this site: Android LocationClient class is deprecated but used in documentation

It seem we should use an import: However I can't import this class..

Any Ideas ?


I have found in this page: h2ttps://

with seemingly similar problem, a speculation that: "Seems to be part of Play services 5.0." I wonder if that is the case -- has anybody tried this ?


Make sure you have the following item in your gradle dependency:

dependencies {
    compile ''

Please Don't use compile ''

In versions of Google Play services prior to 6.5, you had to compile the entire package of APIs into your app. In some cases, doing so made it more difficult to keep the number of methods in your app (including framework APIs, library methods, and your own code) under the 65,536 limit.

From version 6.5, you can instead selectively compile Google Play service APIs into your app. For example, in your case you just needed this.

compile ''
compile ''

To use fused api to get last location you must have compile ''.

For more Information

Hope it helps

Below might help,

  1. You should have play service latest revision 22 downloaded.
  2. Add this line in dependencies compile ''

It should import the respective package in project.

I encountered the same issue, and solved it by updating Google Play Services from 17 to the latest (currently 22) in Android SDK Manager, as mentioned in the comments.

To do that in Eclipse:

  • Delete google-play-services_lib project from your Eclipse
  • Follow Step 3 of Adding SDK Packages. When you launch Android SDK Manager, it should say "Update available: Rev 22" for Google Play Services. Check it and click "Install N packages" to update it.
  • Follow Setting Up Google Play Services to import google-play-services_lib project again.

LocationClient is deprecated. You have to use GoogleApiclient, like this:

1: Declare a GoogleApiClient variable

private GoogleApiClient mGoogleApiClient;

2: Instantiate

mGoogleApiClient = new GoogleApiClient.Builder(mThisActivity)

3: Implement Callback

public class YourClass extends BaseFragment implements
    GoogleApiClient.OnConnectionFailedListener, LocationListener {

    public void onConnectionFailed(ConnectionResult result) {
        // your code goes here

    public void onConnected(Bundle connectionHint) {
        //your code goes here

    public void onConnectionSuspended(int cause) {
        //your code goes here       

4: Start to get Location Updates:

            mGoogleApiClient, mLocationRequest, this);

5: Remove Location Updates:

LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);

6: Get Last Known Location:

private Location mCurrentLocation;

mCurrentLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);

Follow this steps if you are using eclipse :-

  1. Update Google play library from SDK Manger.
  2. Delete old google-play-services_lib from workspace and remove all dependency.
  3. Import update google-play-services_lib and make sure copy to workspace option is selected

  1. Add google-play-services_lib to build path of project it should be showing relative path

  2. If step it is not working restart eclipse .

It's a similar question to issue and answer given here:

In Android Studio:

  1. Right click on your projects "app" folder and click on -> module settings

  2. Click on the "dependencies" tab

  3. Click on the + sign to add a new dependency and select "Library Dependency" Look for the library you need and add it

Need Your Help

Google Analytics reports root as "/"

google-analytics universal-analytics

I have the following tracking code integrated on a customers page: