ANDREW BROGDON: Hey, everybody, and welcome
to the first episode of the "Mobile Ads Garage,"
where we cover the nuts and bolts of mobile ads code
in a format that's just like my grandma-- short and sweet.
I'm Andrew Brogdon, a developer programs
engineer with the Google Mobile Ads SDK team.
We've heard from a lot of our publishers
that you'd love more technical content.
So we're here to get our hands dirty, to wire things up, turn
them on, and see how they work.
We'll have screencasts of real code, hack
on real applications, and, with the help
of my intrepid partner, Gary the graphics guy,
we'll show you the results.
So if you've ever taken a look at the AdMob documentation
and thought, that's great, but could you
have a ginger explain it to me in a format I
can watch on my phone, turns out we can do that.
For our first episode, we're going
to focus on how easy it is to get started with the SDK.
Let's imagine that I'm in an application-- exactly.
One of the simplest ways to monetize an app
is just by adding a banner.
But there's also interstitial ads like these,
or even native ads like these.
The one thing all these formats have in common
is the Mobile Ads SDK.
Properly importing and referencing it in your project
is step one.
So let's take a look at how to do it.
We'll start with iOS.
So here we are in Xcode with a very simple Hello World app
that I'd like to import the SDK into.
So how do I do it?
Well, here are the steps.
I'll be using CocoaPods today.
So the first step is to create or update the PodFile.
Then I'll run pod install, which will download the SDK
and integrate it into the project.
And then I'll open the workspace file that CocoaPods creates.
And I'll be right back in Xcode ready to go.
So here I am in the root directory of my Xcode project.
And I'm going to open the PodFile in a text editor.
And I'm going to drop in some text.
If you're familiar with CocoaPods,
this should look really familiar to you.
The important part is this line right here.
That tells CocoaPods that the project
has a dependency on version 7.0 or higher of the Mobile Ads
SDK.
So I'll save this.
And then I'll run pod install, which
will download the SDK automatically and integrate it
into my project.
And as you can see, we've got a lot more stuff in this folder
now.
So I'm going to open up that workspace file.
And now I'm right back in Xcode.
And just like any other framework,
I can use an import statement to reference it
in one of my files.
And now that I have GADBannerView,
which is an AdMob class, it's properly recognized.
So you know the SDK is in here.
We try to make it as easy as possible to integrate
mobile ads.
Time is money, and we're all about keeping costs down.
For example, the garage behind me-- that's
not even a real garage.
This is, like, a holodeck situation.
Watch, I could be in outer space.
Or I could be swimming with the dolphins.
I could even be backstage with Justin Bieber
if I wanted to be.
Gary, get it-- oh.
Legal didn't approve the-- so I shouldn't even
do the Bieber joke at all?
Well, legal fees aside, we try to keep costs down so
we can keep your revenue up.
Let's take a look at importing the SDK into an Android Studio
project.
OK, so here I am in Android Studio with a Hello World app
that I'd like to get the SDK into.
So what are the steps?
For Android, there is just two.
First, I'll update the app's build.gradle file
to add a dependency on Mobile Ads.
Then I'll do a Gradle sync, and I'm ready to go.
OK, here's my build.gradle.
And I'm going to go to the dependency section
and add a line.
That's right down here.
The Google Mobile Ads SDK is part of Google Play services.
So what we're doing is telling Gradle to pull in just the ads
code with play-services-ads.
And the numbers at the end are the version.
You should always try to use the latest one.
Now that that's done, I'm going to do a Gradle sync.
That's where Gradle pulls in all the resources my project needs,
checks all the references, and makes sure everything's OK.
If this is the first time you've used Google Play services,
Android Studio might pop up a window
and ask you to download something called the Google
Repository.
If that happens, don't worry.
That's just Android Studio and Gradle
downloading the SDK for you.
OK, now that we've finished the Gradle sync,
let me come back to my activity and try
to use one of the SDK's classes.
Here we go.
You can see it automatically suggesting
the package and class, so the SDK is definitely
in the project now.
So that's it.
Getting the SDK into a project is the first step
toward displaying ads and earning revenue.
In our next video, we'll cover how
to use the SDK to display banners
on both iOS and Android.
In the meantime, I've got some great resources for you,
like our AdMob Quick Starts for iOS and Android,
which have notes for Java, Objective C, and Swift.
We also have sample code up on GitHub
for both operating systems, so check those out
if you're interested.
You might also like AdMob's mobs no nonsense guide
to app monetization.
It's an overview of monetization strategies
that includes code and tips from other engineers.
If you've got a technical question relating
to anything you've just seen, stop by our support forum.
And if you've got a question about this video series
or a tip on something you'd like us to cover,
leave a comment below, and Gary and I will see you next time.
[MUSIC PLAYING]