Firebase:无法解析google auth和GoogleSignInResult库

时间:2016-09-07 10:46:42

标签: 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;  

我得到的错误是

Cannot resolve symbol Auth
Cannot resolve symbol GoogleSignInResult

我的项目build.gradle看起来像

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

我的模块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'
}

以下是错误

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()

感谢。

2 个答案:

答案 0 :(得分:11)

有了这两个依赖项:

  compile 'com.google.firebase:firebase-auth:9.4.0'
  compile 'com.google.firebase:firebase-core:9.4.0'

您还需要添加以下内容。这是您需要包含的部分,即Play Services Auth就是这样:

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

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

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

答案 1 :(得分:0)

包含

dependencies {
    compile 'com.firebase:firebase-client-android:2.5.2+'
}

如果您收到构建错误抱怨重复文件,您可以选择通过将packagedOptions指令添加到build.gradle文件来排除这些文件:

android {
    ...
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE-FIREBASE.txt'
        exclude 'META-INF/NOTICE'
    }
}