-
[Android] android 와 firebase 연동하기Android/공부 2020. 9. 29. 13:04
1. Firebase 홈페이지 (console.firebase.google.com)에서 구글 로그인 후 새 프로젝트 추가하기
⑴ 프로젝트 추가를 눌러 새 프로젝트 생성
⑵ 앞으로 사용할 프로젝트 이름 입력
⑶ [계속] 버튼을 눌러 다음으로 진행
⑷ 구글 계정 선택 후 [프로젝트 만들기] 클릭
2. 안드로이드 프로젝트와 파이어베이스 연결하기
⑴ 안드로이드와 파이어베이스 환경설정
안드로이드 버튼을 눌러 프로젝트 연결 창으로 이동
이 화면이 뜨면 아래 처럼 나오는 안드로이드 프로젝트 패키지 이름을 입력한다.
google-services.json 파일을 다운받아 안드로이드 프로젝트에 넣어준다.
buildscript { repositories { // Check that you have the following line (if not, add it): google() // Google's Maven repository } dependencies { // ... // Add the following line: classpath 'com.google.gms:google-services:4.2.0' // Google Services plugin } } allprojects { // ... repositories { // Check that you have the following line (if not, add it): google() // Google's Maven repository // ... } }
안드로이드 프로젝트의 Gradle → build.gradle(Project) 에 다음 코드를 추가하고
apply plugin: 'com.android.application' android { // ... } dependencies { // ... implementation 'com.google.firebase:firebase-core:17.0.0' // Getting a "Could not find" error? Make sure that you've added // Google's Maven repository to your root-level build.gradle file } // Add the following line to the bottom of the file: apply plugin: 'com.google.gms.google-services' // Google Play services Gradle plugin
build.gradle(Module: app) 에 다음 코드까지 추가하고 sync now 를 눌러준다.
⑵ Firebase 이메일 로그인 기능 사용 설정
[Authentication → Sign-in method → 이메일/비밀번호 : 사용설정 허용]
사용설정을 허용해주지 않으면 안드로이드 앱에서 로그인이 진행되지 않는다.
'Android > 공부' 카테고리의 다른 글
[android] Cloud Firebase 데이터 쓰기 및 읽기 (0) 2020.10.27 [android] firebase 회원가입과 로그인 (0) 2020.09.29 [안드로이드] RecyclerView 리사이클러뷰 예제 (0) 2020.06.30 [안드로이드] RecyclerView 리사이클러뷰 (0) 2020.06.29 [안드로이드] Fragment 프래그먼트 예제 (0) 2020.06.26