On this page17 sections
- Prerequisites
- Connection With Previous Lectures
- Learning Objectives
- Lesson
- 1. AdMob vs AdSense
- 2. The Six Ad Formats
- 3. Test Ads First — Always
- 4. Create the Project and Add the Plugin
- 5. Android Setup
- 6. iOS Setup
- Code Examples
- Common Beginner Mistakes
- Best Practices
- Mini Challenge
- Practice Questions
- Practice Answers
- Key Takeaways
Lecture 001 — What Is AdMob & Project Setup
| Category | 1 — AdMob Basics |
| Lecture | 001 of 010 |
| Estimated video length | 16 min |
| Target | Flutter 3.44 · Dart 3.12 · google_mobile_ads 9 |
| Level | Beginner |
| Source code | GitHub — 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
StatefulWidgetandNavigatorknowledge
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_adsand the app id to Android and iOS - Know why we use Google's test ids while developing
Lesson
1. AdMob vs AdSense
| AdMob | AdSense | |
|---|---|---|
| Where | Android and iOS apps | Websites |
| Code | google_mobile_ads plugin | A script on the page |
Same company, same payments, different products. A Flutter app uses AdMob.
2. The Six Ad Formats
| Format | What the user sees | Good place |
|---|---|---|
| Banner | A strip at the top or bottom | Lists and detail screens |
| Interstitial | Full-screen ad | Between screens, after a task |
| App open | Full-screen as the app returns | App resume |
| Native | Ad styled like your own content | Inside a list or feed |
| Rewarded | Full-screen, user chooses to watch for a reward | "Watch to unlock" |
| Rewarded interstitial | Full-screen with a reward, starts by itself after a warning | Between 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
flutter create admob_demo
cd admob_demo
flutter pub add google_mobile_ads5. Android Setup
In android/app/src/main/AndroidManifest.xml, add the permission above <application>,
and the app id inside it:
<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>:
<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; thecstr6suwn9entry is Google's own.
Code Examples
Example 1 — Is the Plugin Installed?
Open pubspec.yaml; under dependencies: you should see:
dependencies:
flutter:
sdk: flutter
google_mobile_ads: ^9.1.0Run 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
- What is the difference between AdMob and AdSense?
- Which format starts with a warning and gives a reward?
- Why do we use test ids?
- What happens on Android without the app id
meta-data?
Practice Answers
- AdMob serves ads in mobile apps; AdSense serves ads on websites.
- Rewarded interstitial.
- Real ads clicked by the developer count as invalid traffic and can suspend the account.
- 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