32

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'
}
halfer
  • 19,824
  • 17
  • 99
  • 186
Dan Grahn
  • 9,044
  • 4
  • 37
  • 74

1 Answers1

41

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();
Joshua Pinter
  • 45,245
  • 23
  • 243
  • 245
Pavel Dudka
  • 20,754
  • 7
  • 70
  • 83
  • 11
    Developing for Android is horrible. I have to completey rewrite the project I am working on every few months because IDE and SDK changes completely break everything. Already sitting another 5 hours on my project, trying to get it compile again with the updated IDE. I am so looking forward the iphone implementation – John Feb 04 '16 at 16:37
  • 1
    @John keep us posted – Pavel Dudka Feb 04 '16 at 17:05
  • @John use clean architecture, this way you will only have to change code in one class. – hyena Dec 07 '17 at 00:45