0

i am new to GeoFencing and i am trying to add API to the GoogleApiClient instance.But it is showing error like can't find variable LocationServices. Here is my code:

private void createGoogleApi() {
    Log.d(TAG, "createGoogleApi()");
    if ( googleApiClient == null ) {
        googleApiClient = new GoogleApiClient.Builder( this )
                .addConnectionCallbacks( this )
                .addOnConnectionFailedListener( this )
                .addApi(LocationServices.API)
                .build();
    }
}

And my gradle is

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

Manifest file

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.INTERNET" />
 <meta-data
        android:name="com.google.android.geo.API_KEY"
        android:value="Server_key" />

Can you pls look into this.or else you can provide some other docs or links for reference.Thanks

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Vikash Kumar
  • 395
  • 5
  • 17

3 Answers3

0

In gradle add play-services location

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

once you check all the updates are done in SDK.

sasikumar
  • 12,540
  • 3
  • 28
  • 48
0

I think you are missing out something like this:

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

for further reference see here

Rushi Ayyappa
  • 2,708
  • 2
  • 16
  • 32
0

You just need to add below line in your app level build.gradle file

compile 'com.google.android.gms:play-services:10.0.1'
Mahesh Babariya
  • 4,560
  • 6
  • 39
  • 54