https://firebase.google.com/docs/cli?authuser=0&hl=ko#install_the_firebase_cli
node 설치버전 확인 후 전역으로 firebase-tools 설치
$ node -v
v17.8.0
$ npm install -g firebase-tools
firebase login 을 시도 (비로그인시 브라우저를 통해 인증)
$ firebase login
flutterfire_cli 를 전역으로 설치한 후에 다음 경로를 $PATH 에 등록
$ dart pub global activate flutterfire_cli
$ export PATH="$PATH":"$HOME/.pub-cache/bin"
$ flutterfire -v
0.2.7
플러터 앱에서 지원하는 플랫폼 (iOS, Android, Web) 을 선택
$ flutterfire configure
$ flutter pub add firebase_core
import 'package:firebase_core/firebase_core.dart';
import 'firebase_options.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp(
options: DefaultFirebaseOptions.currentPlatform,
);
runApp(const MyApp());
}
your-flutter-proj $ flutter run
주석해제
# Uncomment this line to define a global platform for your project
platform :ios, '11.0'
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"
$ cd ios
$ pod install
m1 mac 의 경우 CocoaPods cloud not find compatible versions for pod "Firebase/Firestore"
에러가 나는 경우 다음을 입력
$ sudo arch -x86_64 gem install ffi
$ arch -x86_64 pod install --repo-update
android/app/build.gradle 파일의 compileSdkVersion 을 31 로 교체
Warning: The plugin cloud_firestore requires Android SDK version 31.
For more information about build configuration, see https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
Warning: The plugin firebase_auth requires Android SDK version 31.
For more information about build configuration, see https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
Warning: The plugin firebase_core requires Android SDK version 31.
For more information about build configuration, see https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
Warning: The plugin firebase_storage requires Android SDK version 31.
For more information about build configuration, see https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
One or more plugins require a higher Android SDK version.
Fix this issue by adding the following to /Users/allegromoth/Documents/flutter-source/flutter-ui/android/app/build.gradle:
android {
compileSdkVersion 31
...
}
cloud_firestore 에 지정된 minSdkVersion 이 19 이기 때문에 android/app/build.gradle 의 minSdkVersion 을 19로 교체
/Users/allegromoth/Documents/flutter-source/flutter-ui/android/app/src/debug/AndroidManifest.xml Error:
uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:cloud_firestore] /Users/allegromoth/Documents/flutter-source/flutter-ui/build/cloud_firestore/intermediates/library_manifest/debug/AndroidManifest.xml as the library might be using APIs not available in 16
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project's minSdk version to at least 19,
or use tools:overrideLibrary="io.flutter.plugins.firebase.firestore" to force usage (may lead to runtime failures)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:cloud_firestore] /Users/allegromoth/Documents/flutter-source/flutter-ui/build/cloud_firestore/intermediates/library_manifest/debug/AndroidManifest.xml as the library might be using APIs not available in 16
Suggestion: use a compatible library with a minSdk of at most 16,
or increase this project's minSdk version to at least 19,
or use tools:overrideLibrary="io.flutter.plugins.firebase.firestore" to force usage (may lead to runtime failures)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 58s
┌─ Flutter Fix ─────────────────────────────────────────────────────────────────────────────────┐
│ The plugin cloud_firestore requires a higher Android SDK version. │
│ Fix this issue by adding the following to the file │
│ /Users/allegromoth/Documents/flutter-source/flutter-ui/android/app/build.gradle: │
│ android { │
│ defaultConfig { │
│ minSdkVersion 19 │
│ } │
│ } │
│ │
│ Note that your app won't be available to users running Android SDKs below 19. │
│ Alternatively, try to find a version of this plugin that supports these lower versions of the │
│ Android SDK. │
│ For more information, see: │
│ https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration │
└───────────────────────────────────────────────────────────────────────────────────────────────┘
Exception: Gradle task assembleDebug failed with exit code 1
┌─ Flutter Fix ────────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project requires a newer version of the Kotlin Gradle plugin. │
│ Find the latest version on https://kotlinlang.org/docs/gradle.html#plugin-and-versions, then │
│ update /Users/allegromoth/Documents/flutter-source/flutter-ui/android/build.gradle: │
│ ext.kotlin_version = '<latest-version>' │
└──────────────────────────────────────────────────────────────────────────────────────────────┘
Exception: Gradle task assembleDebug failed with exit code 1
https://kotlinlang.org/ 에 보면 타이틀에 최신버전을 확인가능
android/build.gradle 의 ext.kotlin_version 값을 1.8.0 으로 교체
https://developer.android.com/studio/releases/gradle-plugin#kts
android/build.gradle 파일과
android/gradle/wrapper/gradle-wrapper.properties 파일에서 아래 안내대로 수정
┌─ Flutter Fix ────────────────────────────────────────────────────────────────────────────────────┐
│ [!] Your project needs to upgrade Gradle and the Android Gradle plugin. │
│ │
│ To fix this issue, replace the following content: │
│ /Users/allegromoth/Documents/flutter-source/flutter-ui/android/build.gradle: │
│ - classpath 'com.android.tools.build:gradle:<current-version>' │
│ + classpath 'com.android.tools.build:gradle:7.1.2' │
│ /Users/allegromoth/Documents/flutter-source/flutter-ui/android/gradle/wrapper/gradle-wrapper │
│ .properties: │
│ - https://services.gradle.org/distributions/gradle-<current-version>-all.zip │
│ + https://services.gradle.org/distributions/gradle-7.4-all.zip │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
Exception: Gradle task assembleDebug failed with exit code 1
메서드가 64K개를 초과하는 앱에 관해 멀티덱스 사용 설정한다.
https://developer.android.com/studio/build/multidex
android/app/build.gradle 에 multiDexEnabled = true
추가
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
...
minSdkVersion 19
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled = true
}