강의

멘토링

로드맵

인프런 커뮤니티 질문&답변

D Y님의 프로필 이미지
D Y

작성한 질문수

[왕초보편] 앱 8개를 만들면서 배우는 안드로이드 코틀린(Android Kotlin)

파이어베이스 이메일로그인

09:55 질문입니다!

작성

·

259

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

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

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
질문자

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

D Y님의 프로필 이미지
D Y

작성한 질문수

질문하기