firebase createUserWithEmailAndPassword在android中不起作用 [英] firebase createUserWithEmailAndPassword is not working in android

查看:138
本文介绍了firebase createUserWithEmailAndPassword在android中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用createUserWithEmailAndPassword方法创建用户,但无法这样做. 正在调用OnAuthenticate方法,但用户对象为null,并且在Firebase控制台内未创建任何用户. 这是我的代码,也可以在线获得.

I'm trying to use the createUserWithEmailAndPassword method to create users but not able to do so. The OnAuthenticate method is being called but user object is null and no user is being created inside firebase console. Here is my code, which is the one available online as well.

MAinActivity.java

private static FirebaseAuth mAuth;
private static FirebaseAuth.AuthStateListener mAuthListener;
private static String TAG = "RegisterDEbug";
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //setContentView(R.layout.activity_main);
    mAuth = FirebaseAuth.getInstance();
    mAuthListener = new FirebaseAuth.AuthStateListener() {
        @Override
        public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
            waitForDebugger();
            FirebaseUser user = firebaseAuth.getCurrentUser();
            if (user != null) {
                // User is signed in
                Log.d(TAG, "onAuthStateChanged:signed_in:" + user.getUid());
            } else {
                // User is signed out
                Log.d(TAG, "onAuthStateChanged:signed_out");
            }
            // ...
        }
    };
    mAuth.addAuthStateListener(mAuthListener);
    mAuth.createUserWithEmailAndPassword("9199999989@pintech.com", "corrfecthorsebatterystaple")
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    waitForDebugger();
                    Log.d(TAG, "Authentication successful");
                    if (!task.isSuccessful()) {
                        //Toast.makeText(this, "Authentication failed.",  Toast.LENGTH_SHORT).show();
                    }
                }
            });
}

app.properties

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'

        classpath 'com.google.gms:google-services:3.0.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

app.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.pt.reg"
        minSdkVersion 10
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.google.android.gms:play-services:9.0.2'
    //compile 'com.google.android.gms:play-services-auth:9.0.2'

    compile 'com.google.firebase:firebase-core:9.0.2'
    compile 'com.google.firebase:firebase-auth:9.0.2'
}

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

注意- 我已经尝试从firebase尝试使用Web解决方案来创建可以正常运行的用户.

Note - I have tried web solution from firebase for creating a user which works fine.

推荐答案

我也遇到了这个问题.我用来测试应用程序的密码太短了.我将其扩展为更长的密码,并且可以正常工作.您必须符合Google的密码复杂性标准.

I had this problem too. The password I was testing the app with was just too short. I extended it to a longer password and it worked. You have to meet google's password complexity standards.

这篇关于firebase createUserWithEmailAndPassword在android中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆