Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot resolve symbol GooglePlayServicesClient on new Android Studio Project

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'
}
like image 585
Dan Grahn Avatar asked Mar 27 '15 14:03

Dan Grahn


1 Answers

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();
like image 92
Pavel Dudka Avatar answered Nov 20 '22 06:11

Pavel Dudka