파이어베이스 SDK설치를 중점으로 정리해보았습니다.
1. 프로젝트 만들기

2. Android앱에 Firebase 추가

gradlew signingReport을 안드로이드 스튜디오의 터미널에서 이용하면(Ctrl+Enter이용) SHA-1 구할 수 있음
3. google-services.json 다운로드 후 App 폴더로 옮기기


google-services.json파일을 다운로드 하고 그 파일을 해당 프로젝트 폴더의 app폴더에 옮깁니다.
(파일탐색기가 가장 편했음)
4. SDK
혼돈이 왔던 부분이었습니다.
그 이유는 안드로이드 스튜디오의 그래들 파일 코드와 파이어베이스에서 추가하라고 하는 파이어베이스 코드는 동떨어져 보이기 때문입니다.
buildscript {
repositories {
// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
dependencies {
...
// Add the dependency for the Google services Gradle plugin
classpath 'com.google.gms:google-services:4.3.13'
}
}
allprojects {
...
repositories {
// Make sure that you have the following two repositories
google() // Google's Maven repository
mavenCentral() // Maven Central repository
}
}
위의 코드는 파이어베이스에서 Gradle 파일(<project>/build.gradle)에 추가하라고 하는 내용입니다.
하지만 우리는 프로젝트 수준 Gradle 파일에서 저 내용을 찾아볼 수 없을 수도 있는데요, 그 이유는...
https://developer.android.com/studio/releases/gradle-plugin?hl=ko#updating-plugin
Android Gradle 플러그인 출시 노트 | Android 개발자 | Android Developers
Android 스튜디오 빌드 시스템은 Gradle을 기반으로 하며 Android Gradle 플러그인에는 Android 앱을 빌드하는 데 사용하는 몇 가지 추가 기능이 있습니다.
developer.android.com
업데이트 되었습니다.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.3.1' apply false
id 'com.android.library' version '7.3.1' apply false
id 'org.jetbrains.kotlin.android' version '1.7.20' apply false
id 'com.google.gms.google-services' version '4.3.10' apply false //추가된 내용
}
그래서 결론은 위와 같이 맨 밑에 1줄만 추가해 주면 됩니다.
plugins {
id 'com.android.application' // 기본적으로 추가되어있음
id 'org.jetbrains.kotlin.android'
id 'com.google.gms.google-services' // 추가
}
android {...}
dependencies {
//밑의 두줄 추가
implementation platform('com.google.firebase:firebase-bom:31.1.1')
implementation 'com.google.firebase:firebase-analytics-ktx'
...
}
다행히 Gradle 파일(<project>/<app-module>/build.gradle)은 큰 혼동은 오지 않았습니다.
'개발 > 파이어베이스' 카테고리의 다른 글
[Firebase] 2. Firebase Authentication 시작하기 (+구글로그인) (0) | 2023.01.17 |
---|