Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot resolve symbol 'Auth' for google integration in android studio

i am new in androidstudio. i have done integration of google in eclipse but am having issues in studio. i am following step by step from this site : https://developers.google.com/identity/sign-in/android/sign-in?configured=true

but i am having an issue. i am getting an error that Cannot resolve symbol 'Auth' which i need for API and also cannot resolve 'SignInButton', see the code:

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.SignInButton;
import com.google.android.gms.common.api.GoogleApiClient;


public class MainActivity extends AppCompatActivity implements GoogleApiClient.OnConnectionFailedListener {
GoogleSignInOptions gso;
    GoogleApiClient mGoogleApiClient;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestEmail().build();
       mGoogleApiClient = new GoogleApiClient.Builder(this)
    .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
    .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
    .build();
    }

    @Override
    public void onConnectionFailed(ConnectionResult connectionResult) {

    }
}

this is my project gradle:

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.3.0'
        classpath 'com.google.gms:google-services:1.5.0-beta2'

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

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

this is my app gradle:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.2"

    defaultConfig {
        applicationId "com.creaa.admin.googlesignin"
        minSdkVersion 11
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_7
        targetCompatibility JavaVersion.VERSION_1_7
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.1.0'
    apply plugin: 'com.google.gms.google-services'

}

Please help me.

like image 574
Parth Anjaria Avatar asked Nov 18 '15 06:11

Parth Anjaria


2 Answers

  • Put apply plugin: 'com.google.gms.google-services' beneath apply plugin: 'com.android.application'.

  • Add compile 'com.google.android.gms:play-services-auth:8.3.0' inside dependencies block. This will add related dependencies to your project.

like image 158
Aaron He Avatar answered Oct 07 '22 11:10

Aaron He


With the latest version (2.2.2) what I had to do in order to fix this issue was to add the line below as a dependency into my app/build.gradle file

compile 'com.google.android.gms:play-services-auth:9.8.0'

Hope it helps.

like image 6
iomv Avatar answered Oct 07 '22 11:10

iomv