Cannot resolve GoogleSignIn and GoogleSignInClient

Viewed 30599

I am not able to use GoogleSignIn(com.google.android.gms.auth.api.signin.GoogleSignIn ) and GoogleSignInClient(com.google.android.gms.auth.api.signin.GoogleSignInClient ) while implementing Google Sign In in Android Studio while I can access other classes in App like

com.google.android.gms.auth.api.signin.GoogleSignInAccount;
com.google.android.gms.auth.api.signin.GoogleSignInOptions;
com.google.android.gms.common.SignInButton;

A strip down version of my build.gradle(app) file is as follow

android {

}

dependencies {

    compile 'com.google.android.gms:play-services-auth:11.4.2'
    compile('com.google.api-client:google-api-client-android:1.23.0') {
        exclude group: 'org.apache.httpcomponents'
    }
    compile('com.google.apis:google-api-services-gmail:v1-rev72-1.23.0') {
        exclude group: 'org.apache.httpcomponents'
    }
    implementation 'com.google.gms:google-services:3.1.2'
}

apply plugin: 'com.google.gms.google-services'

and my build.gradle(package) is

buildscript {

    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.0'
        classpath 'com.google.gms:google-services:3.1.2'
    }
}

Any help would be appreciated

6 Answers

For me I was applying a plugin for the google play services in my app's build.gradle:

apply plugin: 'com.google.gms.google-services'

along with that in my Project's Build.gradle I had google services.

buildscript {
    ext.kotlin_version = '1.1.60'
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.google.gms:google-services:3.1.2' // <== this guy
        classpath 'com.android.tools.build:gradle:3.0.0'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

I remember I added them with some compiling issues. But apparently I didn't need them.

By removing them I found there were no more issues with the gms versions.

EDIT

So removing solved my issue initially, but gave me issues later with google sign in. adding the apply plugin: 'com.google.gms.google-services' to the bottom of my projects gradle instead of at the top did actually solve it.

In the build.gradle Module script, I had to add these two dependencies, then "Sync Now" and issue resolved for me.

dependencies {  
    // Your own command lines
    //...

    compile 'com.google.android.gms:play-services-drive:11.8.0'
    compile 'com.google.android.gms:play-services-auth:11.8.0'
}

Can't you use any newer version? e.g. 11.6.0. Try to update your Google Repository as well. (Tools->Android->SDK Manager->SDK Tools under Support Repository)

Add this line in build.gradle module file under dependencies.

implementation 'com.google.firebase:firebase-auth:21.0.1'

For example:

dependencies {

    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'com.google.firebase:firebase-auth:21.0.1'
    implementation 'com.google.firebase:firebase-database:20.0.2'
    implementation 'com.google.android.gms:play-services-auth:20.2.0'
    implementation 'com.google.firebase:firebase-firestore:24.0.0'
    implementation 'com.android.support:multidex:1.0.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    implementation 'androidx.navigation:navigation-fragment:2.3.5'
    implementation 'androidx.navigation:navigation-ui:2.3.5'
    implementation 'de.hdodenhof:circleimageview:3.1.0'
    testImplementation 'junit:junit:4.+'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'


}
Related