2
我正在使用Firebase網站上的代碼示例。出於某種原因,我似乎根本沒有得到onComplete方法,並在輸入if語句後卡住。請指教。謝謝。無法在Firebase上創建新用戶
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
}
我一直都啓用了電子郵件/密碼狀態。我添加了Internet清單的權限。但仍然得到相同的結果。 – arthiks
你添加了google-services.json嗎? –
已將谷歌服務json文件添加到應用程序文件夾下,並且兩個gradle文件都已更新。 – arthiks