我正在尝试使用 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/