gpt4 book ai didi

android - firebase createUserWithEmailAndPassword 在 android 中不起作用

转载 作者:太空宇宙 更新时间:2023-11-03 11:29:10 25 4
gpt4 key购买 nike

我正在尝试使用 createUserWithEmailAndPassword 方法来创建用户,但无法这样做。正在调用 OnAuthenticate 方法,但用户对象为空,并且没有在 firebase 控制台内创建用户。这是我的代码,也是在线提供的代码。

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 的网络解决方案来创建一个运行良好的用户。

最佳答案

我也遇到过这个问题。我用来测试应用程序的密码太短了。我将其扩展为更长的密码并且有效。您必须满足 Google 的密码复杂性标准。

关于android - firebase createUserWithEmailAndPassword 在 android 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37707780/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com