I'm trying to test LocationService example as in http://developer.android.com/training/location/retrieve-current.html I fall in error which is really similar to
Can't Import com.google.android.gms.location.LocationServices
but I can't resolve.
I installed Google play services which version (in my Android SDK Manager ) is 17. I know that latest release is 19 but I'm not able to update version from SDK manager, I can't find any options for doing so.
in my code:
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
first two are fine, third is getting:
import.... cannot be resolved
Edit 12/1/2015
I'm using Eclipse.
You need to compile Google Play Services library into your project.
If you're using AndroidStudio:
Open up build.gradle
and to you dependencies
tag add this:
compile 'com.google.android.gms:play-services:6.+'
So it looks like:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services:6.+'
}
With the new Play Services library you can selectively compile APIs (you might not need the whole library but just a part of it). You'd go for:
compile 'com.google.android.gms:play-services-location:6.+'
More about selective compilation here.
I solved my problem but I don't know exactly how...
First I run Help >> Check for Updates
After doing so I updated Android SDK Tools and Android SDK Platform Tools from SDK Manager, then version of Google Play Services became 22 (before was 17).
My projects had then a red exclamation next to them... and an error saying
Google-play-services_lib Unable to resolve target 'android-9
I deleted google-play-services_lib from my Package Explorer, then re-add library using Import >> Existing Android Code Into Workspace
I don't know exactly wich operation solved the problem... i made so many attempts...
IMPORTANT
After updating SDK i came in an error saying
This Android SDK requires ADT version 23.0.0 or above.
so basically I uninstalled ADT (which version was 22.x) including:
Tracer for OpenGL ES
and install version 23 doing this
as mentioned here [[This Android SDK requires ADT version 23.0.0 or above. Current version is 22.6. Please update ADT to the latest version?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With