Import com.google.android.gms.location.LocationServices, unable to update location services

I am trying to check the LocationService example, as in http://developer.android.com/training/location/retrieve-current.html I am mistaken, which really looks like

Unable to import com.google.android.gms.location.LocationServices

but I canโ€™t decide.

I installed google pley services, the version of which (in my Android SDK Manager) is 17. I know that the latest version is 19, but I canโ€™t update the version from the SDK manager, I canโ€™t plan any options for this.

in my code:

import com.google.android.gms.location.LocationListener; import com.google.android.gms.location.LocationRequest; import com.google.android.gms.location.LocationServices; 

firts two excellent, the third gets: " import .... cannot be resolved "

Edit 12/1/2015

I am using eclipse

+8
android
source share
2 answers

You need to compile the Google Play Services library into your project.

If you are using AndroidStudio:

Open build.gradle and the dependencies tag add this:

 compile 'com.google.android.gms:play-services:6.+' 

It looks like this:

 dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.google.android.gms:play-services:6.+' } 

In the new Play Services library, you can selectively compile the API (you may not need the entire library, but only part of it). Would you go for:

 compile 'com.google.android.gms:play-services-location:6.+' 

Read more about selective compilation here .

+15
source share

I solved my problem, but I donโ€™t know exactly how ...

First I launch Help -> Check for Updates

After that, I updated the Android SDK Tools and Android SDK Platform Tools from the SDK Manager, then the version of Google Play Services became 22 (it was 17 before).

My projects had a red exclamation next to them ... and an error message

 Google-play-services_lib Unable to resolve target 'android-9 

I removed google-play-services_lib from my package explorer and then re-added the library using Import -> Existing Android Code in the workspace

I donโ€™t know exactly which operation solved the problem ... I made so many attempts ...

IMPORTANT

After updating the SDK, I came up with an error saying

 This Android SDK requires ADT version 23.0.0 or above. 

so basically I removed ADT (which version was 22.x), including:

  • Android Traceview
  • Android Hierarchy Viewer
  • Android Development Tools
  • Android DDMS
  • Tracer for OpenGL ES

    and install version 23 by doing this

as mentioned here [[ This Android SDK requires ADT version 23.0.0 or higher. The current version is 22.6. Upgrade ADT to the latest version?

+1
source share

All Articles