On this page17 sections
  1. Prerequisites
  2. Connection With Previous Lectures
  3. Learning Objectives
  4. Lesson
  5. 1. AdMob vs AdSense
  6. 2. The Six Ad Formats
  7. 3. Test Ads First — Always
  8. 4. Create the Project and Add the Plugin
  9. 5. Android Setup
  10. 6. iOS Setup
  11. Code Examples
  12. Common Beginner Mistakes
  13. Best Practices
  14. Mini Challenge
  15. Practice Questions
  16. Practice Answers
  17. Key Takeaways

Lecture 001 — What Is AdMob & Project Setup

Category1 — AdMob Basics
Lecture001 of 010
Estimated video length16 min
TargetFlutter 3.44 · Dart 3.12 · google_mobile_ads 9
LevelBeginner
Source codeGitHub — urraan_admob_final

Your app is free, but servers, stores and your time are not. AdMob is Google's way to earn from a mobile app by showing ads. Before any code, we learn the ad formats, install the plugin and add Google's test app id so nothing real is ever clicked.

Contents

Prerequisites · Connection · Objectives · Lesson · Code Examples · Common Mistakes · Best Practices · Mini Challenge · Practice Questions · Answers · Takeaways


Prerequisites

  • A running Flutter app on Android or iOS (AdMob does not serve ads on web)
  • Basic StatefulWidget and Navigator knowledge

Connection With Previous Lectures

Earlier courses built screens and saved data. This course turns a finished screen into one that earns. We build one demo app with a button for every ad format.


Learning Objectives

By the end of this lecture you will be able to:

  • Explain what AdMob is and how it differs from AdSense
  • Name the six ad formats and when to use each
  • Add google_mobile_ads and the app id to Android and iOS
  • Know why we use Google's test ids while developing

Lesson

1. AdMob vs AdSense

AdMobAdSense
WhereAndroid and iOS appsWebsites
Codegoogle_mobile_ads pluginA script on the page

Same company, same payments, different products. A Flutter app uses AdMob.

2. The Six Ad Formats

FormatWhat the user seesGood place
BannerA strip at the top or bottomLists and detail screens
InterstitialFull-screen adBetween screens, after a task
App openFull-screen as the app returnsApp resume
NativeAd styled like your own contentInside a list or feed
RewardedFull-screen, user chooses to watch for a reward"Watch to unlock"
Rewarded interstitialFull-screen with a reward, starts by itself after a warningBetween levels

3. Test Ads First — Always

Google publishes sample ids that always return a test ad. We use them for the whole course. Never tap your own real ads while developing — AdMob can suspend an account for invalid traffic. Test ads are safe and clearly labelled "Test Ad".

4. Create the Project and Add the Plugin

bash
flutter create admob_demo
cd admob_demo
flutter pub add google_mobile_ads

5. Android Setup

In android/app/src/main/AndroidManifest.xml, add the permission above <application>, and the app id inside it:

xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-permission android:name="com.google.android.gms.permission.AD_ID" />

    <application ...>
        <!-- Google's sample AdMob app ID. Replace with your own before release. -->
        <meta-data
            android:name="com.google.android.gms.ads.APPLICATION_ID"
            android:value="ca-app-pub-3940256099942544~3347511713"/>
        ...

The app crashes on start if this meta-data is missing.

6. iOS Setup

In ios/Runner/Info.plist, inside the first <dict>:

xml
<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>
<key>NSUserTrackingUsageDescription</key>
<string>This identifier will be used to deliver personalized ads to you.</string>
<key>SKAdNetworkItems</key>
<array>
    <dict>
        <key>SKAdNetworkIdentifier</key>
        <string>cstr6suwn9.skadnetwork</string>
    </dict>
</array>
  • GADApplicationIdentifier — the iOS sample app id (Android and iOS use different ids).
  • NSUserTrackingUsageDescription — the text of the iOS tracking prompt.
  • SKAdNetworkItems — lets Google's ad network attribute installs. Google publishes a longer list for production; the cstr6suwn9 entry is Google's own.

Code Examples

Example 1 — Is the Plugin Installed?

Open pubspec.yaml; under dependencies: you should see:

yaml
dependencies:
  flutter:
    sdk: flutter
  google_mobile_ads: ^9.1.0

Run flutter pub get, then flutter run. The default counter app should still start — it proves the manifest edit did not break anything. We add real ad code from Lecture 003.


Common Beginner Mistakes

1. Missing app id on Android — the app closes immediately and the log mentions that the AdMob app id is missing from AndroidManifest.xml. Add the meta-data inside <application>.

2. Using the Android id on iOS — the two platforms have different app ids.

3. Tapping your own real ads — use test ids in development; invalid clicks can get the account suspended.

4. Testing on web — google_mobile_ads does not support web.


Best Practices

  • Keep test ids in the project until the last lecture
  • Put the app id in the manifest and Info.plist, never in Dart
  • Keep ads out of the first screen a new user sees

Mini Challenge

Open AndroidManifest.xml and Info.plist and find the two app ids. Which one ends in ~3347511713?


Practice Questions

  1. What is the difference between AdMob and AdSense?
  2. Which format starts with a warning and gives a reward?
  3. Why do we use test ids?
  4. What happens on Android without the app id meta-data?

Practice Answers

  1. AdMob serves ads in mobile apps; AdSense serves ads on websites.
  2. Rewarded interstitial.
  3. Real ads clicked by the developer count as invalid traffic and can suspend the account.
  4. The app crashes at start.

Key Takeaways

  • AdMob = apps, AdSense = websites
  • Six formats: banner, interstitial, app open, native, rewarded, rewarded interstitial
  • Android and iOS each need an app id and (for iOS) a tracking description
  • Use Google's test ids until you are ready to publish