34

I am new to Android development. I am learning to use Parse.com backend service and get stuck early on.

I am following tutorial to create application that uses Google Maps Android API v2. What I've done :

  1. download sample project from parse
  2. Import AnyWall-android\Anywall folder from downloaded project to Android Studio
  3. Rebuild project

Then I get a bunch of errors here :

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesClient;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.location.LocationClient;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap.CancelableCallback;
import com.google.android.gms.maps.GoogleMap.OnCameraChangeListener;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.Circle;
import com.google.android.gms.maps.model.CircleOptions;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.LatLngBounds;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;

common, location, and maps highlighted red. The question is how to resolve these errors?

I appreciate any kind of help or direction (What should I check? Is it about missing library? If it is, what library should I add and where to get it?)

har07
  • 88,338
  • 12
  • 84
  • 137

7 Answers7

27

Can't find the class com.google.android.gms.location.LocationClient (android)

There is some problem with the last GPS lib. You have to use an older version than the latest(6.+). Try with an older version. I didn't see anything inside the doc deprecated or missing about the LocationClient.class...

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

Community
  • 1
  • 1
user4352520
  • 286
  • 3
  • 3
  • Oh wow. Had the exact same problem (AnyWall demo too!) and this solved it. Would never have thought about it. Thanks! – Muz Dec 21 '14 at 14:44
22

I think the best solution is, add compile API on your Gradle. services-location has this method.

 compile 'com.google.android.gms:play-services-maps:9.8.0'
 compile 'com.google.android.gms:play-services-location:9.8.0'

if you wish to include other services, please refer here: https://developers.google.com/android/guides/setup (scroll down)

Md Imran Choudhury
  • 9,343
  • 4
  • 62
  • 60
12

Google Play Services is now modular, you can select the packages you want from it.

To get analytics add:

compile 'com.google.android.gms:play-services-analytics:7.3.0'

to you build.gradle's dependencies section

P.S replace 7.3.0 with new version as they arrive, or replace with "+" to always get the latest

marmor
  • 27,641
  • 11
  • 107
  • 150
8

Android Studio is complaining that it can't find the Play Services library.

Follow the steps here to ensure Google Play Services SDK is installed (specifically, make sure 'Google Repository' is installed along with 'Google Play Services'): http://developer.android.com/google/play-services/setup.html#Install

Then, make sure the following is added to the dependencies{} block in your build.gradle:

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

Clean and rebuild.

Bryan Dunlap
  • 1,156
  • 10
  • 7
  • thanks for reply. You're right, I haven't installed Google Play Services SDK. But I have another problem regarding gradle build system (I'm currently working on this), so I can't check `dependencies{}` and still have the same error. – har07 Mar 08 '14 at 01:02
6

Add this line you build.gradle in Gradle Scripts folder

dependencies {
        compile 'com.google.android.gms:play-services:11.2.0'
    }

with this i solved this issue.

banoth ravinder
  • 1,314
  • 15
  • 18
1

Previous answers were correct.

But in gradle:3.0 the compile configuration is now deprecated and should be replaced by implementation or api.

Check out more information in the documentation - API and implementation separation.

RredCat
  • 5,259
  • 5
  • 60
  • 100
  • 1
    I ran into this issue and switching `implementation` to `compile` actually solved the issue, but I'm not sure why, if `implementation` is supposed to do the same thing? – Luke Pighetti Sep 30 '20 at 00:51
0

Its just a common mistake in my case, I just remove default ""flutter:"" keyword in pubspec file while managing package