[MUSIC PLAYING]
ANDREW BROGDON: Hey everybody, and welcome to another episode
of "Firecasts."
I'm Andrew Brogdon from the Mobile Ads SDK team.
And on today's episode, I'm going
to show you how to get Firebase and AdMob working together
in an Android app using Gradle.
First, we'll link an app with Firebase.
Then we'll download the Google Services JSON file.
Next we'll configure the Gradle plugin that uses that file,
and finally add the individual services
that belong in the app.
All right, so step one is linking an app, which
we'll do in the AdMod console.
So I'll see you in a browser window.
I'll include a guide at the end of this video
with more info on how this linking works.
But for now, one of the easiest ways to get started
is just to go to the Analytics tab in the AdMob console
and click this nice Get Started With Firebase button.
When I click that, I get to a list of my AdMob apps.
And I can click the Link to Firebase button
to link one to Firebase.
That gives me a prompt for my app's package
name, which is needed for the configuration stuff
to work later.
And depending on whether you've already
created a Firebase project or not,
you may have some choices on the next screen.
This is what you get if you've never created a Firebase
project before.
Clicking Continue will take you to the next screen--
one that looks like this-- telling you
that you now have a linked app.
And so that's step one.
Step two is to download the Google Services JSON config
file, which is really easy because the screen I just
showed you has a link to it, right there.
Just click that link and you'll be
sent to the Firebase console, and the download
will start automatically.
Once it's downloaded, I can go into an Android Studio project
and drag it right into the source tree like that.
It goes in the root folder of the app source.
And it will be used later by the Google Services plugin.
All right, so I've got an app linked
and I've downloaded the JSON file
that contains configuration info for my Firebase project.
Now it's time to get the Gradle plugin for Google Services
configured.
So we'll head into Android Studio.
So here I'm back in Android Studio,
and I'm looking at the project level build.gradle file file.
That's the one that applies not just to the app,
but everything in the project's source tree.
And so I'm just going to add a little class path here
for the Google Services plugin, which is new.
And we're doing a gradle sync.
There we go.
With that done, I can head into the apps build.gradle.
And add a line at the bottom to apply that plugin.
There we go.
This plugin uses the Google Services JSON
file to inject configuration data into the app
when it builds, and it also does some other Firebasey setup
kind of stuff.
Cool, so that's steps one, two, three finished.
Now it's time to add individual Firebase services.
I'm just talking about AdMob today,
so that's the one we'll be adding.
I can do that the same way I always have
through Gradle dependencies.
So for AdMob with Firebase, that Gradle artifact
is called Firebase-adds.
There we go.
There are, by the way, a ton of these artifacts available.
Here's a list of the services along with Gradle dependencies
that go with them, which you can find in the Firebase Android
setup guide.
And you can see there's a bunch in here--
Realtime Database, Authentication, everything
you might want.
All right, so that's all four steps finished,
which means I can come back into my activity file now
and start messing around with AdMob classes like AdView.
And you can see the type is resolving,
so you know the SDK has been properly imported.
And there we go, Firebase and AdMob in an app,
working together, and it only took a couple minutes.
That's it for this "Firecast."
Please leave your questions in the comments below,
or reach out on Twitter and G+ with the hashtag #AskFirebase.
By the way, if you like seeing videos about mobile ads,
I have a whole other series just about that.
It's got screencasts, feature breakdowns, clones,
moose repellent, hairless cats, and sweaters, you name it.
It's called "The Mobile Ad Garage."
So if you're interested in mobile ads tech, check it out.
In the meantime, we'll be dropping a new "Firecast"
every few days.
So don't forget to hit that Subscribe button
and stay up to date.
I'm Andrew Brogdon, and thanks for watching.
[MUSIC PLAYING]