我正在使用Firebase网站上的代码示例。出于某种原因,我似乎根本没有使用onComplete方法,并在输入if语句后卡住了。请指教。谢谢。
if(isRegistering){
Log.d("TEST", "isRegistering"); // <- THIS PRINTS
mAuth.createUserWithEmailAndPassword(email, password)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
Log.d("TEST", "success"); // <- DOESN'T PRINT
}
else {
Log.d("TEST", "fail"); // <- DOESN'T PRINT
}
}
});
}
更新:添加了gradle数据。
模块:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:design:26.+'
testCompile 'junit:junit:4.12'
compile 'com.google.firebase:firebase-auth:11.0.2'
}
apply plugin: 'com.google.gms.google-services'
项目
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}