Firebase:无法解析google auth和GoogleSignInResult库

Has*_*azi 5 android firebase firebase-authentication

我刚开始使用Android,我正在寻找使用Google Firebase进行Google登录.不幸的是我无法导入

import com.google.android.gms.auth.api.Auth;
import com.google.android.gms.auth.api.signin.GoogleSignInResult;  
Run Code Online (Sandbox Code Playgroud)

我得到的错误是

Cannot resolve symbol Auth
Cannot resolve symbol GoogleSignInResult
Run Code Online (Sandbox Code Playgroud)

我的项目build.gradle看起来像

dependencies {
    classpath 'com.android.tools.build:gradle:2.1.3'
    classpath 'com.google.gms:google-services:3.0.0'
}
Run Code Online (Sandbox Code Playgroud)

我的模块build.gradle看起来像

apply plugin: 'com.google.gms.google-services'
.......
.......
.......
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:24.2.0'
    compile 'com.android.support:design:24.2.0'
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    compile 'com.android.support:support-v4:24.2.0'
    compile 'com.google.firebase:firebase-auth:9.4.0'
    compile 'com.google.firebase:firebase-core:9.4.0'
}
Run Code Online (Sandbox Code Playgroud)

以下是错误

Error:(229, 29) error: cannot find symbol variable disconnect_button
Error:(227, 29) error: cannot find symbol variable sign_out_button
Error:(225, 22) error: cannot find symbol variable sign_in_button
Error:(214, 5) error: method does not override or implement a method from a supertype
Error:(222, 5) error: method does not override or implement a method from a supertype
Error:(117, 45) error: package Auth does not exist
Error:(60, 25) error: cannot find symbol variable Auth
Error:(210, 30) error: cannot find symbol variable sign_out_and_disconnect
Error:(206, 13) error: cannot find symbol variable mStatusTextView
Error:(201, 55) error: cannot find symbol variable firebase_status_fmt
Error:(200, 13) error: cannot find symbol variable mStatusTextView
Error:(164, 35) error: package Auth does not exist
Error:(151, 44) error: cannot find symbol class GoogleSignInActivity
Error:(204, 30) error: cannot find symbol variable sign_out_and_disconnect
Error:(12, 39) error: package com.google.android.gms.auth.api does not exist
Error:(198, 9) error: cannot find symbol method hideProgressDialog()
Error:(174, 13) error: package Auth does not exist
Error:(15, 46) error: cannot find symbol class GoogleSignInResult
Error:(188, 13) error: package Auth does not exist
Error:(59, 108) error: incompatible types: LoginActivity cannot be converted to OnConnectionFailedListener
Error:(155, 25) error: cannot find symbol method hideProgressDialog()
Error:(200, 55) error: cannot find symbol variable google_status_fmt
Error:(206, 45) error: cannot find symbol variable signed_out
Error:(117, 13) error: cannot find symbol class GoogleSignInResult
Error:(209, 30) error: cannot find symbol variable sign_in_button
Error:(201, 13) error: cannot find symbol variable mDetailTextView
Error:(207, 13) error: cannot find symbol variable mDetailTextView
Error:(203, 30) error: cannot find symbol variable sign_in_button
Error:(136, 9) error: cannot find symbol method showProgressDialog()
Run Code Online (Sandbox Code Playgroud)

谢谢.

Jay*_* RJ 11

有了这两个依赖:

  compile 'com.google.firebase:firebase-auth:9.4.0'
  compile 'com.google.firebase:firebase-core:9.4.0'
Run Code Online (Sandbox Code Playgroud)

您还需要添加下面的一个.这是您需要包含的部分,即Play Services Auth,它是:

compile 'com.google.android.gms:play-services-auth:9.0.2'
Run Code Online (Sandbox Code Playgroud)

并且最后移动apply plugin: 'com.google.gms.google-services'所有这些依赖关系意味着:

apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)