简体   繁体   中英

Android Firebase Email and password authentication does not work

I am trying to create accounts in an Android app using Firebase. When I add the following dependencies in the app build.grade file -

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'
}

I get the following cryptic build error (btw I'm not using any Twitter SDKs or anything to the best of my knowledge):

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

When I change the dependecies to:

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'
}

the app build and compiles fine, but when I try to create the account, I get the following error:

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

I am at a loss as to what I should do because I think I'm using the latest version of the Firebase SDK.

Some more information is that I have used both mFirebaseRef.createUser() and mAuth.createUserWithEmailAndPassword with no success.

I used this link to change the dependencies.

Any help will be deeply appreciated.

You are mixing the legacy SDK :

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

with the new SDK :

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

This will cause a number of problems and is the reason for this error message:

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

For new development, you should use only the new SDK. Delete this line from your dependencies:

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

The latest versions of FirebaseAuth require additional repositories. Make this change to your project (top-level) build.gradle file:

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

The change is excerpted from the Firebase Sample project. It will eliminate this error:

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

you should use the correct firebase authentication version from Google:

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

And you have to setup Firebase as it is described in the official documentation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM