Cannot resolve symbol GooglePlayServicesClient on new Android Studio Project

Dan Grahn picture Dan Grahn · Mar 27, 2015 · Viewed 25.1k times · Source

I just installed Android Studio 1.1.0 and created a new project. I created it with a Login Activity including Google+ login.

As soon as the project opens, I see many errors in PlusBaseActivity.java. These seem to stem around the fact that com.google.android.gms.common.GooglePlayServiceClient is not being imported.

I have NOT changed the code at all and wonder why it isn't running by default. How can I get this to import?

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"

    defaultConfig {
        applicationId "us.grahn.logintest"
        minSdkVersion 16
        targetSdkVersion 22
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.0.0'
    compile 'com.google.android.gms:play-services:7.0.0'
}

Answer

Pavel Dudka picture Pavel Dudka · Mar 27, 2015

GooglePlayServicesClient class has been deprecated for some time. With latest GooglePlayServices release I believe they got rid of it completely.

However, demo project in AndroidStudio still uses old APIs, so it won't compile :(

Essentially, for talking to GooglePlayServices, you should use GoogleApiClient now (as described here https://developer.android.com/google/auth/api-client.html)

Something like:

GoogleApiClient googleApiClient = new GoogleApiClient.Builder(this)
            .addApi(Plus.API)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .build();

................

googleApiClient.connect();