Admob Flutter plugin that shows banner ads using native platform views.

Overview

admob_flutter

Build Status version version GitHub stars GitHub forks GitHub issues

Demo

A Flutter plugin that uses native platform views to show Admob banner ads!

This plugin also has support for Interstitial and Reward ads.

Installation

  • Add this to your package's pubspec.yaml file:
dependencies:
  admob_flutter: "<LATEST_VERSION>"
  • Install it - You can install packages from the command line:
flutter pub get

Android Specific Setup

Update your AndroidManifest.xml

Add your AdMob App ID to your app's AndroidManifest.xml file by adding the <meta-data> tag shown below. You can find your App ID in the AdMob UI. For android:value insert your own AdMob App ID in quotes, as shown below.

You can use these test App ID's from Admob for development:

Android: ca-app-pub-3940256099942544~3347511713
iOS: ca-app-pub-3940256099942544~1458002511
<manifest>
  <application>
    <meta-data
      android:name="com.google.android.gms.ads.APPLICATION_ID"
      android:value="ca-app-pub-3940256099942544~3347511713"/>
  </application>
</manifest>

iOS Specific Setup

Update your Info.plist per Firebase instructions.

<key>GADApplicationIdentifier</key>
<string>ca-app-pub-3940256099942544~1458002511</string>

and add

<key>io.flutter.embedded_views_preview</key>
<true/>

Starting from Beta 6, you also need to display the App Tracking Transparency authorization request for accessing the IDFA, so you have to update your Info.plist to add the NSUserTrackingUsageDescription key with a custom message describing your usage. Below is an example description text:

<key>NSUserTrackingUsageDescription</key>
<string>This identifier will be used to deliver personalized ads to you.</string>

See Prepare for iOS 14+ for more information. You also need to update your ios/Podfile by adding platform :ios, '9.0' at the very top of your file.

Initialize the plugin

First thing to do before attempting to show any ads is to initialize the plugin. You can do this in the earliest starting point of your app, your main function:

import 'package:admob_flutter/admob_flutter.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  // Initialize without device test ids.
  Admob.initialize();
  // Or add a list of test ids.
  // Admob.initialize(testDeviceIds: ['YOUR DEVICE ID']);
}

If you're using iOS, you may also need to request the tracking authorization in order to display personalized ads:

// Run this before displaying any ad.
await Admob.requestTrackingAuthorization();

Supported Platforms

  • 0.3.0 >= iOS
  • 0.2.0 >= AndroidX

Supported Admob features

  • Banner Ads
  • Interstitial Ads
  • Reward Ads
  • Native Ads (Coming soon)

Check out the repository Wiki for more info!

FAQ

  • Why doesn't the Admob Banner class have a dispose method?
    • TL;DR - It's called automatically for you. Longer reason see 94
  • failed to load ad : 3
    • TL;DR - Things are working correctly, Admob didn't give you an ad. If the app id + ad unit is new, give it 24/48 hours. See:161 stackoverflow
    • See all Admob codes
  • Ads are not loading
    • TL;DR - Make sure you have the correct combination of id's per platform. See:161
  • Objective-C based project cannot build
    • TL;DR - You have to enable swift support for your flutter project. See: stackoverflow and 123
  • How do I manage consentement for users in the European Economic Area?
    • Pass nonPersonalizedAds: true to the classes constructor (AdmobBanner, AdmobInterstitial and AdmobReward) in order to not display personalized ads for users who don't give their consent. A way to ask users for their consent is to use the plugin admob_consent. Please note that the new recommended is to use the brand new UMP SDK (Android, iOS).

Recipes

Pull Requests

I welcome and encourage all pull requests. Here are some basic rules to follow to ensure timely addition of your request:

  1. Match the document style as closely as possible.
  2. Please keep PR titles easy to read and descriptive of changes, this will make them easier to review/merge.
  3. Pull requests must be made against master branch for this repository.
  4. Check for existing issues first, before filing an issue.
  5. Check the project board, before filing an issue.
  6. Read the FAQ, before filing an issue.
  7. Have fun!
Comments
  • Banner is re-created/re-loaded with each Navigator push()/pop()

    Banner is re-created/re-loaded with each Navigator push()/pop()

    Banner is reloaded with each Navigator push()/pop(), both onBannerCreated and AdmobAdEvent.loaded are called even the banner is a child of a const StalessWidget, whose build() method isn't called. Admob guidelines does not recommend to refresh banner manually. Is it possible to avoid this behaviour?

    enhancement help wanted more info required 
    opened by kestasb 27
  • Not compatible with latest Firebase packages upgrade

    Not compatible with latest Firebase packages upgrade

    Hi

    i had updated to latest firebase_auth and firebase_storage packages and i am getting the following error on dependencies:[!] CocoaPods could not find compatible versions for pod "nanopb": In Podfile: admob_flutter (from .symlinks/plugins/admob_flutter/ios) was resolved to 0.3.4, which depends on FirebaseAnalytics (~> 6.1.3) was resolved to 6.1.3, which depends on nanopb (~> 0.3.901)

    firebase_auth (from `.symlinks/plugins/firebase_auth/ios`) was resolved to 0.18.0-1, which depends on
      Firebase/Auth (~> 6.26.0) was resolved to 6.26.0, which depends on
        FirebaseAuth (~> 6.5.3) was resolved to 6.5.3, which depends on
          FirebaseCore (~> 6.6) was resolved to 6.7.2, which depends on
            FirebaseCoreDiagnostics (~> 1.3) was resolved to 1.6.0, which depends on
              nanopb (~> 1.30906.0)
    

    Can you help with upgrading your plugin to match latest firebase versions

    Thanks much

    enhancement good first issue iOS 
    opened by pazhut 22
  • android app crashes after build and install

    android app crashes after build and install

    im using these plugins

    flutter_swiper : any
      firebase_auth: ^0.14.0+5
      flutter_facebook_login: ^2.0.1
      shared_preferences: any
      cloud_firestore: ^0.12.9+5
      fluttertoast: ^3.1.3  
      image_picker: ^0.6.1+3
      cached_network_image: ^1.1.1
      intl: ^0.15.8
      google_sign_in: any
      flutter_local_notifications: ^0.8.2
      firebase_messaging: ^5.1.6
      photo_view: ^0.4.2
      firebase_storage: ^3.0.6
      #image_picker_modern: ^0.4.12+1
      animated_text_kit: ^1.3.1
      permission: ^0.1.4 
    

    when i build after adding admob_flutter app crashes on start. also added in manifest.xml

    used latest version admob_flutter: ^0.3.3

    iOS Android Priority 
    opened by sampathkumar7 19
  • Need iOS help?

    Need iOS help?

    Hi @YoussefKababe,

    Awesome work on this plugin! I have an immediate need for banner and interstitial on Android and iOS. I'm newer to Flutter and am still researching PlatformViews however I have experience in iOS. Are you open to PR's?

    enhancement 
    opened by kmcgill88 19
  • why I can‘t use banner ad for ios

    why I can‘t use banner ad for ios

    0.3.3 it's work on android but not work on ios: {error: Request Error: Cannot find an ad network adapter for mediation., errorCode: 8} no matter using test banner id or my banner id

    but interstitial Ad is work on both.

    i add this on my plist.info:

    <key>io.flutter.embedded_views_preview</key>
    	<true/>
    <key>GADApplicationIdentifier</key>
    	<string>ca-app-pub-XXXXX</string>
    

    IDE : XCODE 11.2 BETA

    bug iOS 
    opened by sunjianan9900 18
  • The plugin `admob_flutter` uses a deprecated version of the Android embedding

    The plugin `admob_flutter` uses a deprecated version of the Android embedding

    when i put admob_flutter: ^2.0.0-nullsafety.1 in pubspec, and type on cmd flutter pub get this error occurs!

    The plugin admob_flutter uses a deprecated version of the Android embedding. To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of
    Flutter will remove these deprecated APIs.

    opened by mariamalbarghouti 17
  •   [!] CocoaPods could not find compatible versions for pod

    [!] CocoaPods could not find compatible versions for pod "GoogleAppMeasurement":

    I'm getting following error while using together with firebase_analytics.

        [!] CocoaPods could not find compatible versions for pod "GoogleAppMeasurement":
          In Podfile:
            admob_flutter (from `.symlinks/plugins/admob_flutter/ios`) was resolved to 1.0.0, which depends on
              Google-Mobile-Ads-SDK (~> 7.64) was resolved to 7.67.0, which depends on
                GoogleAppMeasurement (~> 6.0)
    
            firebase_analytics (from `.symlinks/plugins/firebase_analytics/ios`) was resolved to 8.1.2, which depends on
              Firebase/Analytics (= 8.0.0) was resolved to 8.0.0, which depends on
                Firebase/Core (= 8.0.0) was resolved to 8.0.0, which depends on
                  FirebaseAnalytics (~> 8.0.0) was resolved to 8.0.0, which depends on
                    FirebaseAnalytics/AdIdSupport (= 8.0.0) was resolved to 8.0.0, which depends on
                      GoogleAppMeasurement (= 8.0.0)
    
    opened by penguru 16
  • Pin iOS Podspec versions

    Pin iOS Podspec versions

    Pinning the iOS versions required for Admob to work. This will address, https://github.com/YoussefKababe/admob_flutter/issues/74, for the future. If users didn't update their pods (which apparently Flutter doesn't do for you) you could be stuck with an old version of the ad SDK, hence it doesn't know about the new functionality.

    🚀

    enhancement iOS 
    opened by kmcgill88 16
  • After upgrading to flutter 3,i can't build my app this error message keep coming up

    After upgrading to flutter 3,i can't build my app this error message keep coming up

    /Users/pc/development/flutter/.pub-cache/hosted/pub.dartlang.org/admob_flutter-2.0.0/android/src/main/kotlin/com/shatsy/admobflutter/AdmobBannerFactory.kt: (9, 1): Class 'AdmobBannerFactory' is not abstract and does not implement abstract base class member public abstract fun create(p0: Context?, p1: Int, p2: Any?): PlatformView defined in io.flutter.plugin.platform.PlatformViewFactory e: /Users/pc/development/flutter/.pub-cache/hosted/pub.dartlang.org/admob_flutter-2.0.0/android/src/main/kotlin/com/shatsy/admobflutter/AdmobBannerFactory.kt: (10, 3): 'create' overrides nothing e: /Users/pc/development/flutter/.pub-cache/hosted/pub.dartlang.org/admob_flutter-2.0.0/android/src/main/kotlin/com/shatsy/admobflutter/AdmobInterstitial.kt: (63, 29): Null can not be a value of a non-null type String e: /Users/pc/development/flutter/.pub-cache/hosted/pub.dartlang.org/admob_flutter-2.0.0/android/src/main/kotlin/com/shatsy/admobflutter/AdmobReward.kt: (66, 29): Null can not be a value of a non-null type String ../../../../../development/flutter/.pub-cache/hosted/pub.dartlang.org/flare_flutter-3.0.2/lib/flare_render_box.dart:167:26: Warning: Operand of null-aware operation '?.' has type 'SchedulerBinding' which excludes null.

    opened by mohamedMesalm 13
  • Ad failed to load : 3

    Ad failed to load : 3

    Ads are not showing on my phone, but the emulator also shows in test mode. as the error code: Ad failed to load: 3 i'm also sure you did everything right

    opened by hsnbsst 12
  • 'admob_flutter/admob_flutter-Swift.h' file not found'

    'admob_flutter/admob_flutter-Swift.h' file not found'

    === BUILD TARGET firebase_messaging OF PROJECT Pods WITH CONFIGURATION Debug === /usr/local/flutter/.pub-cache/hosted/pub.dartlang.org/admob_flutter-0.3.1/ios/Classes/AdmobFlutterPlugin.m:20:9: fatal error: 'admob_flutter/admob_flutter-Swift.h' file not found #import <admob_flutter/admob_flutter-Swift.h> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated.

    iOS 
    opened by jiharal 11
  • Crash Application when implement mediation

    Crash Application when implement mediation

    Hi, currently i want to implement admob mediation with uniti ads into my application. When i try to implement

    implementation 'com.unity3d.ads:unity-ads:4.0.0' implementation 'com.google.ads.mediation:unity:4.0.0.0'

    Then run application, it will be crashed cause: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/android/gms/ads/reward/RewardedVideoAdListener;

    Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.reward.RewardedVideoAdListener" on path...

    Please help!!

    opened by onstonboy 0
  • admob_flutter not found

    admob_flutter not found

    ios/Runner/GeneratedPluginRegistrant.m:12:9: fatal error: module 'admob_flutter' not found @import admob_flutter;~~~~~~~^~~~~~~~~~~~~1 error generated. note: Using new build system note: Planning note: Build preparation complete note: Building targets in dependency order configure: MacOs: Big Sur 11.6.2 flutter: 1.8.1/Dart:2.7.0 Xcode: 13.2.1 Cocoa pods: 1.11.2

    opened by mahmudulhasan766 0
  • Memory Leak Issue, Tested in Android 11

    Memory Leak Issue, Tested in Android 11

    Hi @kmcgill88, i use your package to show banner ads in my applications. When i check in the devtools, memory usage capacity becomes bigger when admob banner is displayed. Tested in profile mode.

    I think when the page is closed, these banner Ads don't really disappear from memory, they are still there, so there is a memory leak Screen Shot 2021-11-24 at 17 43 35

    opened by yusriltakeuchi 0
  • Display is broken after loading banner ad

    Display is broken after loading banner ad

    Display is broken after loading banner ad!

    enter image description here

    enter image description here

    #flutter doctor -v

    `[√] Flutter (Channel stable, 2.2.3, on Microsoft Windows [Version 10.0.19042.867], locale tr-TR) • Flutter version 2.2.3 at C:\src\flutter • Framework revision f4abaa0735 (2 weeks ago), 2021-07-01 12:46:11 -0700 • Engine revision 241c87ad80 • Dart version 2.13.4

    [√] Android toolchain - develop for Android devices (Android SDK version 30.0.3) • Android SDK at C:\Users\Aksoyhlc\AppData\Local\Android\Sdk • Platform android-30, build-tools 30.0.3 • ANDROID_HOME = C:\Users\Aksoyhlc\AppData\Local\Android\Sdk • ANDROID_SDK_ROOT = C:\Users\Aksoyhlc\AppData\Local\Android\Sdk • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174) • All Android licenses accepted.

    [√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe

    [√] Android Studio (version 4.1.0) • Android Studio at C:\Program Files\Android\Android Studio • Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)

    [√] VS Code (version 1.55.2) • VS Code at C:\Users\Aksoyhlc\AppData\Local\Programs\Microsoft VS Code • Flutter extension can be installed from: https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

    [√] Connected device (2 available) • sdk gphone x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator) • Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.124

    • No issues found!` @kmcgill88

    opened by Aksoyhlc 0
  • admob_flutter Flutter package causing error in Debug mode only

    admob_flutter Flutter package causing error in Debug mode only

    I have been using the admob_flutter package. I was able to successfully debug and run with this package installed. However, it suddenly gives me this error now:

    FAILURE: Build failed with an exception.
    
    * Where:
    Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035
    
    * What went wrong:
    Execution failed for task ':app:compileFlutterBuildDebug'.
    > Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1
    

    The project is able to build and display ads successfully. The error comes up when I'm running debug mode. I have tried:

    • running flutter clean and flutter pub get.
    • Deleting the .gradle folder.
    • Deleting the current instance of the Flutter SDK and installing a new instance of the same verison.
    • Reinstalling the package and downgrading.

    None of the above steps have helped. What could be the issue?

    opened by Oomeeth-iWhiz 1
Releases(3.0.0)
Flutter Plugin for Square In-App Payments SDK

Flutter plugin for In-App Payments SDK The Flutter plugin for Square In-App Payments SDK is a wrapper for the native Android and iOS SDKs and supports

Square 317 Dec 20, 2022
A Flutter plugin to fetch system messages, stacktraces etc.

logcat Flutter plugin to get system messages, stack traces etc and show them in app. Can also be used to get the app logs from a remote device with sh

null 4 Jul 25, 2021
Flutter Facebook Audience Network

facebook_audience_network Facebook Audience Network plugin for Flutter applications (Android & iOS). Banner Ad Native Banner Ad Native Ad Interstitial

Dreamsoft Innovations 148 Oct 1, 2022
A flutter application for attendance registration of students which has nodejs as backend server with mongoDb database.

attandanceregister A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you start

null 7 Dec 17, 2022
Admob Flutter plugin that shows banner ads using native platform views.

Looking for Maintainers. Unfortunately I haven't been able to keep up with demand for features and improvments. If you are interested in helping maint

Kevin McGill 418 Dec 3, 2022
Flutter native ads - Show AdMob Native Ads use PlatformView

flutter_native_ads Flutter plugin for AdMob Native Ads. Compatible with Android and iOS using PlatformView. Android iOS Getting Started Android Androi

sakebook 64 Dec 20, 2022
how to Integrating facebook audience network to flutter app for banner, interstitial, rewarded, native and native banner

fb_ads_flutter_12 A new Flutter project. Getting Started Watch the complite tutorial for integrating Facebook ads into the Flutter app in our Youtube

null 4 Nov 26, 2022
Easy-to-make native ads in flutter using AdMOB SDK.

native_admob_flutter Easy-to-make ads in Flutter with Google's AdMob SDK. English | Português Get started To get started with Native Ads for Flutter,

Bruno D'Luka 81 Dec 12, 2022
In this video, we learn how to do integrate Google Admob with Flutter with latest Flutter 2.0 Google Admob Package.

?? Monetizing Flutter apps with Google AdMob ?? In this video, we learn how to do integrate Google Admob with Flutter with latest Flutter 2.0 Google A

SnippetCoder 14 Nov 30, 2022
A flutter demo app to implement google admob ads

test_ads A Flutter demo app to implement google admob ads. Getting Started important - if you are cloning the repo to your desktop, you will need to p

null 4 Apr 4, 2022
Google mobile ads applovin - AppLovin mediation plugin for Google Mobile Ads (Flutter).

AppLovin mediation plugin for Google Mobile Ads Flutter Google Mobile Ads Flutter mediation plugin for AppLovin. Use this package as a library depende

Taeho Kim 1 Jul 5, 2022
Plugin to integrate Facebook Native Banner Ad

flutter_fbaudience_network Plugin to integrate Facebook Native Ad to Flutter application Warning: The plugin is based on Flutter PlatformView (Android

Duy Duong 8 May 13, 2020
Find The Latest trending and upcoming movies and tv shows with MovieDB app. The app contains all info about movies and tv shows. find similar movies or shows, Browse all genres, video trailers, backdrops, logos, and posters.

MovieDB App Features. Dynamic Theming Search Functionality Onboarding-Screen Select favourite movie Home Screen Tranding movie Movies different catego

Ansh rathod 80 Dec 12, 2022
Plugin to integrate native firebase admob to Flutter application

flutter_native_admob Plugin to integrate Firebase Native Admob to Flutter application Platform supported: iOS, Android Getting Started For help gettin

Duy Duong 63 Dec 21, 2022
A Flutter plugin to create views using concentric transition effect.

Concentric Transition A Flutter plugin to create views using Concentric Transition Clipper. Useful for onboarding, page transitions, custom clippers,

Vladyslav Korniienko 202 Jan 7, 2023
A simple recipe showing application made using Flutter , using card Views MaterialPageRoute etc.

recipes A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if this

Akash Srivastava 1 Oct 31, 2021
Responsive Scaffold - On mobile it shows a list and pushes to details and on tablet it shows the List and the selected item. Maintainer: @rodydavis

responsive_scaffold View the online demo here! On mobile it shows a list and pushes to details and on tablet it shows the List and the selected item.

Flutter Community 346 Dec 2, 2022
Demo of web banner in Flutter

web_carousel How to implement a Web Banner the right way in Flutter. Screenshots Desk: Mobile: Medium Article Here is the Medium Article via the frien

Fred Grott 0 Mar 18, 2022
Display a smart banner on top of the screen of your Flutter Web application.

Smart Banner Display a smart banner on top of the screen of your Flutter Web application. Inspired by smart-app-banner and react-smartbanner Try the o

Guillaume Roux 8 Jul 10, 2023