In this tutorial, we will create firebase configuration and also map that configuration into flutter application. Now, We need to click on Get started is we want to add our flutter app to this FIREBASE project. We can create both Android, IOS configuration depending on what kind of application you are building.
I will click on Android here to start with that and connect my FIREBASE project here to this flutter
Step1:
It will open Wizard to create Firebase config for android. Now we need to provide android package which is Application ID in flutter/android project. you can find Application ID in flutter_project/android/app/build.gradle file like shown below:
defaultConfig { applicationId "com.example.firstproject minSdkVersion 17 targetSdkVersion 30 multiDexEnabled true versionCode flutterVersionCode.toInteger() versionName flutterVersionName }
Step2: Download Google-services.json
In this step download google-services.json file and copy to FlutterProject/android/app folder
Step3: Configure build.gradle with Firebase libraries
As shown in below Add the class path like shown below:
buildscript { ext.kotlin_version = '1.3.50' repositories { google() mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:4.1.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'com.google.gms:google-services:4.3.10' } } allprojects { repositories { google() mavenCentral() } } rootProject.buildDir = '../build' subprojects { project.buildDir = "${rootProject.buildDir}/${project.name}" project.evaluationDependsOn(':app') } task clean(type: Delete) { delete rootProject.buildDir }
Androd/App/build.gradle config: Add the lines as shown in below
apply plugin: 'com.android.application' apply plugin: 'com.google.gms.google-services' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" dependencies { implementation 'com.android.support:multidex:1.0.3' implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation platform('com.google.firebase:firebase-bom:28.4.1') }
Now in app/build.gradle add multiDexEnabled to true to as firebase generates larger size of build files
defaultConfig { applicationId "com.example.firstproject minSdkVersion 17 targetSdkVersion 30 multiDexEnabled true versionCode flutterVersionCode.toInteger() versionName flutterVersionName }
Now Ignore the last step and click on Continue. Now your flutter project is configures with firebase
Comments are closed.