Parth Anjaria
Parth Anjaria

Reputation: 3971

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.

Upvotes: 25

Views: 34374

Answers (8)

Kanad Patil
Kanad Patil

Reputation: 256

  1. open your ANDROID STUDIO
  2. open TOOLS
  3. select FIREBASE
  4. select the authentication
  5. and click on the "Add firebase authentication to your app" button.

done!

(note: make sure you are connected to the internet.)

Upvotes: 0

Makvin
Makvin

Reputation: 3629

Add this in dependency block in your app gradle

implementation 'com.google.android.gms:play-services-auth:16.0.0'

Upvotes: 0

Lakshmikant Deshpande
Lakshmikant Deshpande

Reputation: 844

I faced this issue. I solved it by adding this line in app level gradle file:

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

(at the bottom of the file (important))

and this line in app level dependencies section,

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

(latest version, at the time when I am writing this answer)

Here's the link to the documentation.

Upvotes: 0

Harish Rn
Harish Rn

Reputation: 98

I had the same issue, add compile 'com.google.android.gms:play-services-auth:10.0.1 (your project's latest version) in your app level gradle file.

Upvotes: 1

Aaron Luna
Aaron Luna

Reputation: 39

Add the dependencies for Firebase Authentication and Google Sign-In to your app-level build.gradle file:

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

Upvotes: 1

iomv
iomv

Reputation: 2707

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.

Upvotes: 6

Aaron He
Aaron He

Reputation: 5549

  • 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.

Upvotes: 63

Orkun Kocyigit
Orkun Kocyigit

Reputation: 1147

Try moving apply plugin: 'com.google.gms.google-services' from dependencies to top of your gradle file, just under apply plugin: 'com.android.application'.

EDIT:

Make sure that you have installed the Extras/Google Repository from the SDK Manager and added the compile 'com.google.android.gms:play-services:8.3.0' into your dependency scope.

Upvotes: 1

Related Questions