| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | --- | 
					
						
							|  |  |  | title: connecting-to-firebase | 
					
						
							|  |  |  | --- | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-19 07:29:30 +05:30
										 |  |  | ## Prerequisites
 | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | 1. The Latest Version of Android Studio | 
					
						
							| 
									
										
										
										
											2018-11-19 07:29:30 +05:30
										 |  |  | 2. Device running Android 4.0 or newer | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-19 07:29:30 +05:30
										 |  |  | ### Connect firebase using one of this two ways:
 | 
					
						
							|  |  |  | 1. Connect using Firebase Assistant in Android Studio | 
					
						
							|  |  |  | 2. Connect firebase [using the GUI](https://developer.android.com/studio/write/firebase). | 
					
						
							|  |  |  | 3. Connect firebase manually  | 
					
						
							|  |  |  |   | 
					
						
							|  |  |  | The easiest way to connect to firebase is to use the firebase assistant.  | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-19 07:29:30 +05:30
										 |  |  | #### Connecting using Firebase Assistant in Android Studio
 | 
					
						
							|  |  |  | 1. Create an account in the [Firebase Console](https://console.firebase.google.com).  | 
					
						
							|  |  |  |    - Click add project to add your Android Studio project to it.  | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 2. Install Google Repository | 
					
						
							| 
									
										
										
										
											2018-11-19 07:29:30 +05:30
										 |  |  |    - You can do this by adding the dependency into your project-level build.gradle file like this: | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | ```java | 
					
						
							| 
									
										
										
										
											2018-11-19 07:29:30 +05:30
										 |  |  | allprojects { | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  |   repositories { | 
					
						
							| 
									
										
										
										
											2018-11-19 07:29:30 +05:30
										 |  |  |     maven { | 
					
						
							|  |  |  |       url "https://maven.google.com" // Google's Maven repository | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2018-11-19 07:29:30 +05:30
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | } | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-19 07:29:30 +05:30
										 |  |  | #### Connect firebase [using the GUI](https://developer.android.com/studio/write/firebase). 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 1. Go to Tools > Firebase and select Connect to Firebase | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-19 07:29:30 +05:30
										 |  |  | #### Connect to firebase [manually](https://firebase.google.com/docs/android/setup))
 | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | Having connected your Android Studio project to Firebase, you can either  | 
					
						
							| 
									
										
										
										
											2018-11-19 07:29:30 +05:30
										 |  |  | 1. Click on a product in the firebase assistant and get taken to the Google docs where you will be told how to proceed | 
					
						
							|  |  |  | 2. Go to desired product in **Project Overview** in the Console and click on **Get Started**  | 
					
						
							|  |  |  | 3. Go to the [Firebase docs](https://www.firebase.com/docs/android/quickstart.html) to see how to setup individual products in your project | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | Reading a combination of all three will enable you to setup the product, which includes adding suitable dependencies to your build.gradle file. | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-11-03 05:42:57 +01:00
										 |  |  | **If You Encounter Gradle Sync errors** | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | Try To Change The Firebase-core Version or Firebase-database version |