Skip to main content

Setting up Firestore for flutter App

                                               
  
                   Setting up Firestore for flutter App

Create your project in Firestore go to https://firebase.google.com and follow the steps (self-explanatory) 

  Once you have created the project you will see the App page.  Click on add an App to get started and choose iOS or Android

Add an App for Android:

1)  on firebase.google.com when asks for an "Android package name"
 get the package name of  App from the AndroidManifest.xml, 

 

rest all optional and make sure to download and keep the google-service.json config file.  Click Next and Finish ( ignore all the gibberish we will come to this later )

2) Go back to IDE
copy & paste or drag & drop  google-service.json config file as shown below. 

3) Add a plugin in build.gradle ( project-level see below )

Click open build.gradle 

Add the classpath for google services, PS: version will vary with time


4) Now go to app-level build.gradle 


   open and go all the way to bottom and add below line:
        
      apply plugin: 'com.google.gms.google-services'


 Save!

Add an App for iOS:

1) under Register an App when asks for iOS Bundle ID. go to the Xcode (if you are using mac open Xcode and you will find the Bundle identifier in Runner > general tab).for non-Mac users, it's easy to find the package name which is the same as the android package name but with no separations or symbols. 

eg: a package name com.drflutter.app.first_Flutter_App in android is com.drflutter.app.firstFlutterApp  the bundle identifier in iOS. 

 Click and carry on ignore all the gibberish and finish the App. Make sure to download and save the GoogleService-info.plist file.  

PS: This is only applicable to Mac users as you will need Xcode 

Now Go back to IDE

2) Open Runner.xcodeproj ( reveal in finder ) 
And drag and drop the GoogleService-info.plist as shown in the location image below 


Done!

Last Thing:

Next and the last thing you need to do is going to pubspec.yaml and add the dependencies 

Add the dependencies and click on "packages get"


Well done!

come across and error stating "Cannot fit requested classes in a single dex file"  ?

Comments

Popular posts from this blog

Flutter App’s Link to Google Map

                                                                               Flutter App’s Link to Google Map        Note: I suggest you run a flutter upgrade prior making below amendments     1)  Log in to Google Cloud Platform and create a project for the API Key. Follow the instructions and basic settings.    PS: Billing account won't charge you a penny, Also API key is per project, Save “Your API Key” on a notepad   2)   Now go to  DartPack    https://pub.dev/flutter/packages         Search for  google maps  flutter   3)   Add the dependencies of packages   pubspec.yaml  file to:     ...

Adding a splash screen on Android flutter app

Adding a splash screen on Android flutter app am using 1024 * 1024 dimension image, also remember don't use file names with symbols but underscore "_" Copy and paste the image on to all the mipmap folder under android                                    Next go to drawable and open launch_background.xml and uncomment image assets info  Update with splash image name and source,  see below:     Rerun the Build, close reopen app to see the splash screen !! I like to use my own style/color ( this is optional ). Go to the values folder and create an xml file , I call it colors.xml ( New file > filename.xml ) add the xml properties on newly created file, in our case colors.xml                 <?xml version="1.0" encoding="utf-8" ?>  and the style and color of your choice. ...

Cannot fit requested classes in a single dex file

            Error: Cannot fit requested classes in a single dex file  Scenario:  Building project with cloud_firestore  Error: Fix: Go to app level build.gradle  and append minSdkVersion from 16 to 21, see below: now rerun the build!