Ultimate, Rock-Solid Guide — Supercharge Your .NET MAUI App with AdMob Banner Ads

In this guide, you will learn step-by-step how to create a brand-new .NET MAUI app named showadmobebannerads and integrate Google AdMob banner ads using the Plugin.AdMob NuGet package. Follow along carefully, and you’ll have a working banner ad displayed in minutes.

Step 1 — Create the .NET MAUI Project

  • Open Visual Studio with the .NET MAUI workload installed.
  • Go to File → New → Project and search for MAUI.
  • Select .NET MAUI App and click Next.
  • Name your project: showadmobebannerads.
  • Choose location, confirm the solution name, and click Create.
  • When prompted for target platforms, select .Net 8 or .Net 9, then click Finish.

Step 2 — Install Plugin.AdMob via NuGet

Now, let’s add the AdMob package to your MAUI app.

A — Using Visual Studio NuGet UI:
  • Right-click your project showadmobebannerads.
  • Select Manage NuGet Packages….
  • In the Browse tab, search for: Plugin.AdMob.
  • Click Install and accept the license.

Step 3 — Initialize AdMob in MauiProgram.cs

Open the file MauiProgram.cs (root of your MAUI project). Add .UseAdMob() directly after .UseMauiApp<App>(). Copy the full MauiProgram class below into your project (or update the existing one).
public static class MauiProgram { public static MauiApp CreateMauiApp() { var builder = MauiApp.CreateBuilder(); builder .UseMauiApp() .UseAdMob() .ConfigureFonts(fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); }); #if DEBUG builder.Logging.AddDebug(); //AdConfig.UseTestAdUnitIds = true; #endif return builder.Build(); } }
Line-by-line explanation:
  1. public static class MauiProgram — Declares a static helper class named MauiProgram. This class typically contains the CreateMauiApp factory used by the MAUI bootstrapper.
  2. { — Opening brace for the class body.
  3. public static MauiApp CreateMauiApp() — Defines a public static method that returns the configured MauiApp instance. MAUI calls this to create and configure your app at startup.
  4. { — Opening brace for the method body.
  5. var builder = MauiApp.CreateBuilder(); — Creates a MauiAppBuilder which exposes a fluent API to register services, handlers, fonts, and platform-specific integrations.
  6. builder — Starts the fluent configuration chain on the builder. The following lines are chained calls that add features and configuration to the builder.
  7. .UseMauiApp<App>() — Registers your App class (usually defined in App.xaml.cs) as the MAUI application entry point. This is always required.
  8. .UseAdMob() — Registers and initializes the AdMob plugin with the MAUI app builder. Placing it right after UseMauiApp<App>() ensures the plugin is hooked into the app lifecycle and DI container so AdMob services and renderers are available app-wide.
  9. .ConfigureFonts(fonts => — Begins configuration for custom fonts. MAUI exposes this delegate so you can register fonts that will be available in XAML or C# via their alias names.
  10. { — Opening brace for the fonts configuration lambda.
  11. fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); — Registers the file OpenSans-Regular.ttf and gives it the alias OpenSansRegular. Use that alias in XAML/C# to apply the font.
  12. fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); — Same as above for the semibold variant; registers the font and sets the friendly alias OpenSansSemibold.
  13. }); — Closes the ConfigureFonts call and terminates the fluent call chain with a semicolon.
  14. #if DEBUG — A conditional compilation directive: the code between #if DEBUG and #endif runs only in debug builds (not in Release). Useful for debug-only helpers.
  15. builder.Logging.AddDebug(); — Adds the debug logger provider so you can see debug logs in your IDE output while running Debug builds.
  16. //AdConfig.UseTestAdUnitIds = true; — A commented line that (if supported by the AdMob plugin version) toggles use of test ad unit IDs. During development you should use test ads to avoid policy violations — uncomment this line if your plugin exposes AdConfig and that property.
  17. #endif — Ends the #if DEBUG conditional block.
  18. return builder.Build(); — Builds and returns the configured MauiApp instance. This finalizes all registrations and configuration so MAUI can start the app.
  19. } — Closes the method body.
  20. } — Closes the class body.

Quick notes:

  • Make sure Plugin.AdMob is installed in the project (Step 2). After adding .UseAdMob(), save and rebuild the solution so the plugin types are available.
  • If the plugin exposes an AdConfig or similar helper for enabling test ads, enable that during development to prevent invalid activity on real ad units.

Step 4 — Edit AndroidManifest.xml (Platforms → Android → Resources)

In Visual Studio: expand Platforms → Android , right-click AndroidManifest.xmlOpen With… → choose XML (Text) Editor. Then add the following XML (place it inside your existing <manifest> if one already exists — merge, don't duplicate the <application> tag).
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true"> <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" /> <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-3940256099942544~3347511713" /> </application> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.INTERNET" />
Line-by-line explanation
  1. <application android:allowBackup="true" android:icon="@mipmap/appicon" android:roundIcon="@mipmap/appicon_round" android:supportsRtl="true">
    What it does: Declares your Android application element and sets global app attributes:
    • android:allowBackup="true" — allows the system to back up app data to the user's Google account (keep or set to false per your policy).
    • android:icon="@mipmap/appicon" — default app launcher icon resource.
    • android:roundIcon="@mipmap/appicon_round" — round icon (used on devices/launchers that prefer round icons).
    • android:supportsRtl="true" — enables right-to-left layout support for RTL languages.
    Note: If your manifest already has an <application> element, add the inner tags (activity & meta-data) into the existing element instead of adding a second <application>.
  2. <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:theme="@android:style/Theme.Translucent" />
    What it does: Registers the special Google Mobile Ads SDK activity used for ad overlays, click-throughs, and interstitial behavior.
    • android:name="com.google.android.gms.ads.AdActivity" — required by the Google Mobile Ads SDK.
    • android:configChanges="..." — prevents the activity from being recreated on configuration changes that could interrupt ad display; the list covers keyboard, orientation, UI mode, screen size changes, etc.
    • android:theme="@android:style/Theme.Translucent" — makes the activity translucent so ad overlays and interstitials display properly on top of your UI.
    Why it matters: Missing this activity causes ads (especially interstitials or some banners) to crash or not display correctly.
  3. <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="ca-app-pub-3940256099942544~3347511713" />
    What it does: Supplies your AdMob App ID to the Google Mobile Ads SDK at startup.
    • The value shown (ca-app-pub-3940256099942544~3347511713) is the official sample/test App ID provided by Google. Replace it with your real AdMob App ID (from your AdMob console) before publishing.
    • This <meta-data> must be inside the <application> element.
  4. </application>
    What it does: Closes the application element. (Keep your manifest well-formed — do not duplicate or add a second <application>.)
  5. <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    What it does: Grants the app permission to query network state (e.g., whether the device is on Wi-Fi or mobile data). The Ad SDK uses this to optimize ad loading and caching.
  6. <uses-permission android:name="android.permission.INTERNET" />
    What it does: Grants the app permission to access the internet — required for fetching ads and their assets.

Quick implementation notes

  • In a .NET MAUI project the Android manifest is normally at: Platforms/Android/AndroidManifest.xml. Make sure you edit that file (or your merged manifest) and not some other file.
  • If your manifest already contains the permissions or the AdActivity entry, do not duplicate them — keep one copy only.
  • Always use the real AdMob App ID from your AdMob account for production; continue to use Google's sample/test IDs while developing and testing to avoid policy violations.
  • After updating the manifest, save and rebuild the Android project so the changes take effect.

Step 5 — Initialize Mobile Ads in iOS (AppDelegate.cs)

In Visual Studio: expand Platforms → iOS, double-click AppDelegate.cs to open it. Replace or update the CreateMauiApp override so the Google Mobile Ads SDK is initialized on app startup. Copy the code below into your AppDelegate.cs (or patch the method if it already exists).
[Register("AppDelegate")] public class AppDelegate : MauiUIApplicationDelegate { protected override MauiApp CreateMauiApp() { var app = MauiProgram.CreateMauiApp(); // ✅ Correct initialization of MobileAds MobileAds.SharedInstance.Start(completionHandler: null); return app; } }
Line-by-line explanation
  1. [Register("AppDelegate")]
    This attribute registers the class with the Objective-C runtime under the name AppDelegate. It's required so iOS can locate and instantiate your app delegate during startup.
  2. public class AppDelegate : MauiUIApplicationDelegate
    Declares the AppDelegate class that inherits from MAUI's MauiUIApplicationDelegate. This class handles iOS app lifecycle events and is the correct place to perform early SDK initialization.
  3. protected override MauiApp CreateMauiApp()
    This method overrides the MAUI bootstrapping hook. MAUI calls this to obtain the configured MauiApp instance the app will run.
  4. {
    Begins the method body.
  5. var app = MauiProgram.CreateMauiApp();
    Calls your MauiProgram.CreateMauiApp() factory (the same class you edited earlier) to build the MAUI app. This returns the fully configured MauiApp instance.
  6. // ✅ Correct initialization of MobileAds
    A simple comment that explains the next line. Comments do not affect execution and are safe to keep for clarity.
  7. MobileAds.SharedInstance.Start(completionHandler: null);
    The important initialization call: this invokes the Google Mobile Ads iOS SDK startup routine.
    • MobileAds.SharedInstance returns the SDK singleton instance.
    • Start(...) initializes the SDK so it is ready to load and show ads. Passing null means no completion callback is used here.
    Initializing the SDK on startup ensures ad components, mediation adapters and internal services are prepared before you request ads.
  8. return app;
    Returns the MauiApp instance back to the MAUI host so normal app startup continues.
  9. }
    Closes the method.
  10. }
    Closes the class.

Quick implementation notes

  • If you haven't already, you may need to add using Google.MobileAds; at the top of AppDelegate.cs (depending on your SDK/package name).
  • Ensure the iOS AdMob/GoogleMobileAds package is added to the iOS platform project (or the shared MAUI project) so MobileAds resolves.
  • On iOS you must also add your AdMob App ID to Info.plist as GADApplicationIdentifier (use the official AdMob key and your real App ID for production). Keep using test IDs while developing.
  • Save and rebuild the iOS project after changes. If the app fails to compile, confirm the package and namespace are correct for the Mobile Ads SDK version you installed.

Step 6 — Add AdMob App ID & SKAdNetwork IDs in Info.plist

In Visual Studio: expand Platforms → iOS → Info.plist, right-click and choose Open With → XML (Text) Editor. Find the line:
<string>Assets.xcassets/appicon.appiconset</string>
Paste the code below immediately under that line.
<key>GADApplicationIdentifier</key> <string>ca-app-pub-3940256099942544~1458002511</string> <key>SKAdNetworkItems</key> <array> <dict> <key>SKAdNetworkIdentifier</key> <string>cstr6suwn9.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>4fzdc2evr5.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>2fnua5tdw4.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>ydx93a7ass.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>p78axxw29g.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>v72qych5uu.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>ludvb6z3bs.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>cp8zw746q7.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>3sh42y64q3.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>c6k4g5qg8m.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>s39g8k73mm.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>3qy4746246.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>f38h382jlk.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>hs6bdukanm.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>mlmmfzh3r3.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>v4nxqhlyqp.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>wzmmz9fp6w.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>su67r6k2v3.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>yclnxrl5pm.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>t38b2kh725.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>7ug5zh24hu.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>gta9lk7p23.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>vutu7akeur.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>y5ghdn5j9k.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>v9wttpbfk9.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>n38lu8286q.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>47vhws6wlr.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>kbd757ywx3.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>9t245vhmpl.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>a2p9lx4jpn.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>22mmun2rn5.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>44jx6755aq.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>k674qkevps.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>4468km3ulz.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>2u9pt9hc89.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>8s468mfl3y.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>klf5c3l5u5.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>ppxm28t8ap.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>kbmxgpxpgc.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>uw77j35x4d.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>578prtvx9j.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>4dzt52r2t5.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>tl55sbb4fm.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>c3frkrj4fj.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>e5fvkxwrpn.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>8c4e2ghe7u.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>3rd42ekr43.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>97r2b46745.skadnetwork</string> </dict> <dict> <key>SKAdNetworkIdentifier</key> <string>3qcr597p9d.skadnetwork</string> </dict> <key>GADIsAdManagerApp</key> <true/> </array>
Short explanation (key lines):
  • <key>GADApplicationIdentifier</key> — Declares the AdMob App ID key required by the Google Mobile Ads SDK.
  • <string>ca-app-pub-3940256099942544~1458002511</string> — The sample/test iOS App ID supplied by Google. Replace with your real App ID before publishing.
  • <key>SKAdNetworkItems</key> ... </array> — The SKAdNetwork list (Apple) used for privacy-safe ad attribution; include required networks so installs/conversions are attributed correctly.
  • <key>GADIsAdManagerApp</key><true/> — Optional flag that indicates the app uses Google Ad Manager features.

Step 7 — Add the AdMob Banner in MainPage.xaml

At the very top of your MainPage.xaml file, add this namespace declaration inside the <ContentPage> tag:
xmlns:admob="clr-namespace:Plugin.AdMob;assembly=Plugin.AdMob"
Then replace your existing <Grid> ... </Grid> content with the code below.
<Grid> <Grid.RowDefinitions> <RowDefinition Height="*" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <!-- Main Content --> <!-- ✅ Correct AdMob Usage --> <admob:BannerAd Grid.Row="1" AdSize="SmartBanner"> <admob:BannerAd.AdUnitId> <!-- ✅ Remove the xmlns:x here, it's already declared at top --> <OnPlatform x:TypeArguments="x:String"> <On Platform="Android" Value="ca-app-pub-3940256099942544/6300978111" /> <On Platform="iOS" Value="ca-app-pub-3940256099942544/2934735716" /> </OnPlatform> </admob:BannerAd.AdUnitId> </admob:BannerAd> </Grid>
Short explanation (key lines):
  • <Grid> ... </Grid> — Defines the page layout using rows, one for main content and one for the banner ad.
  • <RowDefinition Height="*" /> — Fills remaining space for app content.
  • <RowDefinition Height="Auto" /> — Automatically sizes the bottom row for the ad banner.
  • <admob:BannerAd ... AdSize="SmartBanner"> — Places the AdMob banner; SmartBanner adapts size for device width.
  • <OnPlatform> ... </OnPlatform> — Supplies platform-specific Ad Unit IDs for Android and iOS (Google test IDs shown here; replace with your real ones before publishing).

Step 9 — Run and See Your Test Banner Ads!

🎉 Congratulations! You’ve successfully integrated Google AdMob banner ads into your .NET MAUI application using ASPX tutorial format. Now, simply run your project on a physical device or emulator — and you’ll see Google’s **test banner ads** appearing at the bottom of your app.
dotnet build dotnet run
✅ If you see a banner ad with “Test Ad” written on it, that means your integration is working perfectly! Later, when you’re ready to go live, replace the **test Ad Unit IDs** with your real AdMob IDs from your Google AdMob account.

Conclusion

In this tutorial, we covered every step required to add AdMob banner ads in a .NET MAUI app, from setting up your environment to displaying test ads. By following these steps, you now have a monetization-ready mobile application that works across Android and iOS. The journey from an empty project to a functioning ad-enabled app is now complete — and you’ve built it with clean, reusable, and production-ready code.

FAQs

1. Why am I seeing only “Test Ad”?

Google shows test ads by default when using test Ad Unit IDs. Replace them with your real AdMob IDs to see live ads after publishing.

2. Do I need a Google AdMob account?

Yes, you must have an approved Google AdMob account to get your own Ad Unit IDs for production use.

3. Can I test ads on an emulator?

Yes, test ads can be viewed on both physical devices and emulators. For live ads, always test on a physical device.

4. Is this method safe for publishing?

Yes, this integration is compatible with Google’s latest policies and .NET MAUI updates. Just ensure you use your own AdMob credentials before release.

5. Can I use this tutorial for interstitial or rewarded ads?

Yes, the concept is similar. You would just replace the BannerAd control with the appropriate ad type and handle its events.