작성
·
183
0
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
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)
}
}
세상에 선생님.... 로그에 The given password is invalid. [ Password should be at least 6 characters ] 이렇게 떠서 6글자 로 해봤더니 성공이라 뜨네요 ㅜㅜㅜㅜ 감사합니다 ㅜㅜㅜ