Android Firebase 电子邮件和密码身份验证不起作用

标签 android firebase firebase-authentication

我正在尝试使用 Firebase 在 Android 应用程序中创建帐户。当我在应用程序 build.grade 文件中添加以下依赖项时 -

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.firebase:firebase-client-android:2.5.2'
    compile 'com.firebaseui:firebase-ui:1.0.1' 
    compile 'com.google.firebase:firebase-auth:10.0.0'//added also tried 10.0.1
    testCompile 'junit:junit:4.12'
}

我收到以下神秘的构建错误(顺便说一句,据我所知,我没有使用任何 Twitter SDK 或任何东西):

Error:Failed to resolve: com.twitter.sdk.android:twitter:2.2.0

当我将依赖项更改为:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.firebase:firebase-client-android:2.5.2'
    compile 'com.firebaseui:firebase-ui:0.6.2'//changed
    compile 'com.google.firebase:firebase-auth:9.8.0'//changed
    testCompile 'junit:junit:4.12'
}

应用程序构建和编译正常,但是当我尝试创建帐户时,出现以下错误:

Projects created at console.firebase.google.com must use the new Firebase Authentication SDKs available from firebase.google.com/docs/auth/

我不知道该怎么做,因为我想我使用的是最新版本的 Firebase SDK。

更多信息是我同时使用了 mFirebaseRef.createUser()mAuth.createUserWithEmailAndPassword 但没有成功。

我用了这个link更改依赖项。

我们将不胜感激任何帮助。

最佳答案

您正在混合 legacy SDK :

compile 'com.firebase:firebase-client-android:2.5.2'

new SDK :

compile 'com.google.firebase:firebase-auth:10.0.0'

这将导致许多问题,并且是出现此错误消息的原因:

Projects created at console.firebase.google.com must use the new Firebase Authentication SDKs available from firebase.google.com/docs/auth/

对于新的开发,您应该只使用新的 SDK。从您的依赖项中删除这一行:

compile 'com.firebase:firebase-client-android:2.5.2'

FirebaseAuth 的最新版本需要额外的存储库。对您的项目(顶级)build.gradle 文件进行此更改:

allprojects {
    repositories {
        jcenter()
        maven { url 'https://maven.fabric.io/public' }
        mavenLocal()
    }
}

更改摘自 Firebase Sample项目。它将消除此错误:

Error:Failed to resolve: com.twitter.sdk.android:twitter:2.2.0

关于Android Firebase 电子邮件和密码身份验证不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41496977/

相关文章:

firebase - ERROR_INVALID_EMAIL,电子邮件地址格式错误。

android - 逐项叠加 HitTest

android - BottomNavigationView 上的所选项目不可见

firebase - 阻止 Firebase 身份验证记住 Google 帐户?

java - Spinner 值自动更新到位置 0,该位置从 firebase 获取数据

java - 如何查询 queryDocumentSnapshot Firestore 内的文档字段

android - 如何将 Firebase 帐户关联到 Google Play 游戏帐户

ios - 火力地堡 : Facebook authentification with Firebase token not working

java - onSensorChanged 和线程,Android

android - 如何创建将出现在 Eclipse 工具提示中的 XML 模式文档?