• 카테고리

    질문 & 답변
  • 세부 분야

    모바일 앱 개발

  • 해결 여부

    미해결

09:55 질문입니다!

22.01.03 06:00 작성 조회수 137

0

-package com.daeyeon.fb_firebase_email_password_auth

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.Button
import android.widget.EditText
import android.widget.Toast
import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.ktx.auth
import com.google.firebase.ktx.Firebase

class MainActivity : AppCompatActivity() {

private lateinit var auth: FirebaseAuth

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)

auth = Firebase.auth

val joinBtn = findViewById<Button>(R.id.joinBtn)
joinBtn.setOnClickListener {

val email = findViewById<EditText>(R.id.emailArea)
val password = findViewById<EditText>(R.id.passwordArea)

Log.d("MAIN", email.text.toString())
Log.d("MAIN", password.text.toString())


auth.createUserWithEmailAndPassword(email.text.toString(), password.text.toString())
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
// Sign in success, update UI with the signed-in user's information
Toast.makeText(this, "성공", Toast.LENGTH_LONG).show()
} else {
// If sign in fails, display a message to the user.
Toast.makeText(this, "실패", Toast.LENGTH_LONG).show()

}
}

}
}
}
이메일 비번을 치고 회원가입을 누르면 자꾸 실패가 떠요!....

답변 2

·

답변을 작성해보세요.

1

박영민님의 프로필

박영민

2022.02.22

엌ㅋㅋㅋㅋㅋ 저도 똑같은 문제였어요 감사합니다

0

아래와 같이 else부분에 Log.d()를 이용해서 task.exception의 내용을 출력해보시겠어요?

이 부분을 실패 부분에 넣어보시면 됩니다.

Log.d(TAG, "createUserWithEmail:failure", task.exception)

 

나오는 로그메세지를 공유해주세요.

 

 

 

auth.createUserWithEmailAndPassword(email, password)
       
.addOnCompleteListener(this) { task ->
           
if (task.isSuccessful) {
               
// Sign in success, update UI with the signed-in user's information
               
Log.d(TAG, "createUserWithEmail:success")
               
val user = auth.currentUser
                updateUI
(user)
           
} else {
               
// If sign in fails, display a message to the user.
               
Log.w(TAG, "createUserWithEmail:failure", task.exception)
               
Toast.makeText(baseContext, "Authentication failed.",
                       
Toast.LENGTH_SHORT).show()
                updateUI
(null)
           
}
       
}
D Y님의 프로필

D Y

질문자

2022.01.03

세상에 선생님.... 로그에 The given password is invalid. [ Password should be at least 6 characters ] 이렇게 떠서 6글자 로 해봤더니 성공이라 뜨네요 ㅜㅜㅜㅜ 감사합니다 ㅜㅜㅜ