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?

Answers


For the benefit of searchers:

If you are following the android tutorial that relates to this, you can add the dependency via the UI.

  1. In Android Studio, go to File > Project Structure.
  2. Go to the dependencies tab.
  3. On the right hand side add a 'Library Dependency'.
  4. Type "com.google.android.gms:play-services" into the searchbox and pick the appropriate dependency.
  5. Then follow @Dmac's 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;

I had to do the following to get my app to compile successfully:

  1. Update my build.grade with 'com.google.android.gms:play-services:<version>'
  2. Add imports as needed:

    import com.google.android.gms.common.api.GoogleApiClient;
    import com.google.android.gms.common.ConnectionResult;
    import com.google.android.gms.common.api.ResultCallback;
    import com.google.android.gms.common.api.Status;
    
  3. In Android Studio: File --> Invalidate/Restart...

  4. Clean build


I had this problem, only with import com.google.android.gms.common.api.GoogleApiClient;I unfortunately had moved <meta-data android:name="com.google.android.geo.API_KEY" android:value="@string/google_maps_key" /> after its relative activity <activity android:name=".MapsActivity" android:label="@string/title_activity_maps" ></activity>. I returned to previous state and the problem was solved.


Add following lines to your dependencies to use Google Places Api interfaces

dependecies{compile 'com.google.android.gms:play-services:11.2.0'
testCompile 'junit:junit:4.12'

}


Just to log the problem.

This happens when there is version conflict. Check the build message, and it will suggest the version you should be importing.

The classpath version in main gradle (classpath 'com.google.gms:google-services:3.1.0') should be complaint with the version of jar included in the app gradle (compile 'com.google.android.gms:play-services-auth:11.0.0')


the question is old ,but now that GoogleApiClient is deprecated I found out that I can't use it anymore and that one should use its substitute, subclasses of GoogleApi .


Need Your Help

Is F# really faster than Erlang at spawning and killing processes?

concurrency f# erlang actor

Updated: This question contains an error which makes the benchmark meaningless. I will attempt a better benchmark comparing F# and Erlang's basic concurrency functionality and inquire about the r...

How do I expand a tuple into variadic template function's arguments?

c++ c++11 arguments tuples

Consider the case of a templated function with variadic template arguments: