Dmac Dmac - 2 months ago 137
Android Question

Cannot Resolve Symbol Google API Client in Android Studio

I'm getting an error in Android Studio for the following:

mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API).build();


I have put this in my manifest,
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />


and
compile 'com.google.android.gms:play-services:6.5.87'
in my gradle dependencies.

I've downloaded the required sdk files as well.

Why do I still get this error?

Answer

Even though not officially listed in the tutorial, you must use the following imports:

import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.GoogleApiClient.ConnectionCallbacks;
import com.google.android.gms.common.api.GoogleApiClient.OnConnectionFailedListener;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;