PhoneAuthProvider没有得到解决?

时间:2017-09-21 10:39:57

标签: android firebase firebase-authentication

我已创建并配置了firebase项目,并启用了电话号码验证并添加了依赖项

gradle:项目级别

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

gradle模块级别

dependencies {
compile 'com.google.firebase:firebase-core:9.2.0'
compile 'com.google.firebase:firebase-messaging:9.2.0'
compile 'com.google.firebase:firebase-auth:9.2.0'
compile 'com.google.android.gms:play-services-auth:9.2.0'
}
apply plugin: 'com.google.gms.google-services'

我无法解析PhoneAuthProvider

private void startPhoneNumberVerification(String phoneNumber) {
// [START start_phone_auth]
PhoneAuthProvider.getInstance().verifyPhoneNumber(
        phoneNumber,        // Phone number to verify
        60,                 // Timeout duration
        TimeUnit.SECONDS,   // Unit of timeout
        this,               // Activity (for callback binding)
        mCallbacks);        // OnVerificationStateChangedCallbacks}

遵循this文档

中的所有步骤

2 个答案:

答案 0 :(得分:6)

version 11.0中添加了电话身份验证。您需要将build.gradle更改为至少需要该版本:

compile 'com.google.firebase:firebase-core:11.4.0'
compile 'com.google.firebase:firebase-messaging:11.4.0'
compile 'com.google.firebase:firebase-auth:11.4.0'

答案 1 :(得分:0)

仅导入所需方法的类。例如,如果要使用getInstance()方法,则必须在顶部导入类PhoneAuthProvider
确保您已将项目与Firebase连接。

赞:

import com.google.firebase.auth.PhoneAuthProvider;