2017-09-25 27 views
-2

My Code錯誤使用火力地堡文檔代碼

auth.signInWithEmailAndPassword(email, password) 
     .addOnCompleteListener(LoginActivity.this , new OnCompleteListener<AuthResult>() { 
    @Override 
    public void onComplete(@NonNull Task<AuthResult> task) { 
     Log.d(TAG, "signInWithEmail:onComplete:" + task.isSuccessful()); 
     FirebaseUser user = auth.getCurrentUser(); 

     // If sign in fails, display a message to the user. If sign in succeeds 
     // the auth state listener will be notified and logic to handle the 
     // signed in user can be handled in the listener. 
     if (!task.isSuccessful()) { 
      Log.w(TAG, "signInWithEmail:failed", task.getException()); 
      Toast.makeText(LoginActivity.this, R.string.auth_failed, 
        Toast.LENGTH_SHORT).show(); 
     } 

    } 
}); 

(它帶給我的注意,我不應該有我的代碼的圖像時,但我認爲它可以更容易看到的錯誤。因此,無論是以上)

我開始一個新的Firebase項目,並希望添加身份驗證。我在android studio中使用了firebase助手,並在建議的文檔代碼中進行了複製,並在創建帳戶和登錄時開始獲取這些錯誤。在網上找不到任何幫助。我發現的最近的人是沒有正確拼寫AuthResult的人。另外有人有錯誤的任務庫。我在這裏錯過了什麼?

+0

please,圖片中沒有代碼 –

+0

感謝您的幫助Tim –

+0

當您將光標移到'email'上時,彈出窗口中有什麼? 「無法解析符號」? –

回答

0

代碼錯位。它不是方法主體的一部分。

0

把它放在你的onCreate()中,這應該修復它。

+0

謝謝。是的,你是對的 –