We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 6
2a2017 ‘eld Firebase to Your Ancoid Project | Firebase
Add Firebase to Your Android Project
Prerequisites
* Adevice running Android 4.0 (Ice Cream Sandwich) or newer, and Google Play
services 11.4.0 or higher
* The Google Play services SDK from the Google Repository, available in the
Android SDK Manager
(https://developer.android.com/studio/intro/update.html#sdk-manager)
* The latest version of Android Studio (http://developer.android.com/sdk), version 1.5
or higher
If you don't have an Android Studio project already, you can download one of our
quickstart samples (https://firebase.google.com/docs/samples/) if you just want to try a
Firebase feature. If you're using a quickstart, remember to get the application ID from
the build. gradie file in your project's module folder (typically app/), as you'll need this
package name for the next step.
Note: If you are upgrading from a 2.X version of the Firebase SDK, see our uparade quide for
Android (https://firebase.google.com/support/guides/firebase-android) to get started.
Add Firebase to your app
If you're using the latest version of Android Studio (version 2.2 or later), we
recommend using the Firebase Assistant
(//developer.android.com/studio/write/firebase.html) to connect your app to Firebase. The
Firebase Assistant can connect your existing project or create a new one for you and
htpssfirebase,google.comidocs/encroisetup 162a2017 ‘eld Firebase to Your Ancoid Project | Firebase
automatically install any necessary gradle dependencies.
If you're using an older version of Android Studio or have a more complex project
configuration, you can still manually add Firebase to your app (#manually_add_firebase)
Use the Firebase Assistant
To open the Firebase Assistant in Android Studio:
Click Tools > Firebase to open the Assistant window.
Click to expand one of the listed features (for example, Analytics), then click the
provided tutorial link (for example, Log an Analytics event).
Click the Connect to Firebase button to connect to Firebase and add the
necessary code to your app.
That's it! You can skip ahead to the next steps (#next_steps).
Manually add Firebase
If you prefer not to use the Firebase Assistant, you can still add Firebase to your app
using the Firebase console
To add Firebase to your app you'll need a Firebase project and a Firebase configuration
file for your app.
1. Create a Firebase project in the Firebase console (//console.firebase.google.com/), if
you don't already have one. If you already have an existing Google project
associated with your mobile app, click Import Google Project. Otherwise, click
Create New Project.
2. Click Add Firebase to your Android app and follow the setup steps. If you're
importing an existing Google project, this may happen automatically and you
can just download the config file
(http://support.google.com/firebase/answer/7015592).
3. When prompted, enter your app's package name. It's important to enter the
package name your app is using; this can only be set when you add an app to
your Firebase project.
4. At the end, you'll download a google-services. json file. You can download this
htpasiirebase,google.comidoestensroisetup 262a2017 ‘eld Firebase to Your Ancoid Project | Firebase
file (http://support.google.com/firebase/answer/7015592) again at any time.
5. If you haven't done so already, copy this into your project's module folder,
typically app/
Note: If you have multiple build variants with different package names defined, each app must be
added to your project in Firebase console,
Add the SDK
If you would like to integrate the Firebase libraries into one of your own projects, you
need to perform a few basic tasks to prepare your Android Studio project. You may
have already done this as part of adding Firebase to your app.
First, add rules to your rootevel build. gradle file, to include the google-services
plugin and the Google's Maven repository:
buildscript {
Wows
dependencies {
Wows
classpath ‘com.google.gns:google-services:3.1.0' // google-services |
+
allprojects {
Mow.
repositories {
Mowe
maven {
url "https://maven.google.com" // Google's Maven repository
}
Then, in your module Gradle file (usually the app/build.gradle), add the apply plugin
line at the bottom of the file to enable the Gradle plugin:
apply plugin: ‘com.android.application’
android {
htpasiirebase,google.comidoestensroisetup2a2017 ‘eld Firebase to Your Ancoid Project | Firebase
Move
dependencies {
Wow
compile ‘com.google.firebase:firebase-core:11.4.0°
// Getting a "Could not find" error? Make sure you have
// the latest Google Repository in the Android SDK manager
// ADD THIS AT THE BOTTOM
apply plugin: ‘com. google.gms.google-services'
You should also add the dependencies for the Firebase SDKs you want to use. We
recommend starting with com. google. firebase: firebase-core, which provides
Google Analytics for Firebase functionality. See the list of available libraries
(https/firebase. google.com/docs/android/setup available libraries)
Note: To learn more about what the Gradle plugin does, see our Gooale Services Gradle Plugin
guide (https://developers.google.com/android/guides/google-services-plugin).
Available libraries
The following libraries are available for the various Firebase features.
Gradle Dependency Line Service
com.google.firebasesfirebase-core:11.4.0 Analytics
com.google.firebaserfirebase-database:11.4.0 Realtime Database
com.google.firebasesfirebase-storage:11.4.0 Storage
com. google firebaserirebase-crash:11.4.0 Crash Reporting
com.google.firebaserfirebase-auth:11.4.0 Authentication
com.google.firebaserfirebase messaging:11.4.0 Cloud Messaging
com.google.firebaserfirebase-config:11.4.0 Remote Config
htpasiirebase,google.comidoestensroisetup2a2017 ‘eld Firebase to Your Ancoid Project | Firebase
com.google.firebase-firebase-invites:11.4.0 Invites and Dynamic Links
com, google firebaserirebase-ads:11.4.0 ‘AdMob
com. google. firebase-firebase-appindexing:11.4.0 ‘App Indexing
com. google.firebasesirebase perf:11.4.0 Performance Monitoring
Note: com. google. firebase: firebase~core isa recommended alias for the
com. google. firebase: firebase-analytics library.
Next steps
Learn about Firebase:
+ Explore sample Firebase apps (https‘//firebase. google.com/docs/samples).
* Get hands-on experience with the Firebase Android Codelab
(https://codelabs. developers. google.com/codelabs/firebase-android/).
* Learn more with the Firebase in a Weekend
(https//www.udacity.com/course/ud0352) course.
‘Add Firebase features to your app:
* Gain insights on user behavior with Analytics
(https://firebase. google.com/docs/analytics/).
+ Set up user authentication with Authentication
(https://firebase.google.com/docs/auth/).
* Store user info with Realtime Database (https://firebase. google.com/docs/database/)
or blob data with Cloud Storage (httpsy/firebase.google.com/docs/storage/)..
* Send notifications to users with Cloud Messaging
(https/firebase.google.com/docs/cloud-messaging/).
* Find out when and why your app is crashing with Crash Reporting
(httpsi/firebase.google.com/docs/crash/).
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 3.0
License (http://creativecommons.org/licenses/by/3.0/), and code samples are licensed under the
htpasiirebase,google.comidoestensroisetup2a2017 ‘eld Firebase to Your Ancoid Project | Firebase
Apache 2.0 License (http://www.apache.org/licenses/LICENSE-2.0). For details, see our Site Policies,
(https://developers.google.com/terms/site-policies). Java is a registered trademark of Oracle and/or its
affiliates.
Last updated September 19, 2017.
htpasiirebase,google.comidoestensroisetup