B4A Library FirebaseAdMob - Admob ads integrated with Firebase backend

Discussion in 'Additional libraries, classes and official updates' started by Erel, Jun 9, 2016.

Thread Status:
Not open for further replies.
  1. Erel

    Erel Administrator Staff Member Licensed User

    This library required B4A v6+.

    This library allows showing AdMob ads. It is integrated with Firebase services so you can better track and analyze the results.

    It supports banner ads and interstitial ads (full screen ads).

    First you need to follow the Firebase integration tutorial: https://www.b4x.com/android/forum/threads/integrating-firebase-services.67692/
    Make sure to include the Ads manifest snippet.

    Full example that shows a banner ad and an interstitial ad when clicking on the activity:
    Sub Process_Globals

    End Sub

    Sub Globals
    Private BannerAd As AdView
    Private IAd As InterstitialAd
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
    "BannerAd""ca-app-pub-3940256099942544/6300978111", BannerAd.SIZE_SMART_BANNER)
    Dim height As Int
    If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then
        If 100%x > 100%y Then height = 32dip Else height = 50dip
        height = 90dip
    End If
    Activity.AddView(BannerAd, 0dip100%y - height, 100%x, height)
    End Sub

    Sub Activity_Click
    If IAd.Ready Then IAd.Show
    End Sub

    Sub IAD_AdClosed
    'prepare a new ad
    End Sub
    These are test ids and they will show test ads.

    Edit: It is also required to request user consent for personalized ads. See this tutorial: https://www.b4x.com/android/forum/threads/firebaseadmob-and-user-consent.93347/#post-590593

    V1.60 - Few new requirements, explained here: https://www.b4x.com/android/forum/threads/firebaseadmob-v1-6.108552/
    V1.50 - Adds support for requesting consent.
    V1.31 - Fixes an issue related to InMobi mediation ads.
    V1.30 - Adds support for rewarded video ads: https://www.b4x.com/android/forum/threads/firebaseadmob-rewarded-video-ads.71430/
    V1.20 - Adds support for native ads: https://www.b4x.com/android/forum/t...integrated-with-firebase-backend.67710/page-3
    Last edited: Oct 21, 2019
  2. incendio

    incendio Well-Known Member Licensed User

    Great, and when will B4A v6+ released?
  3. Erel

    Erel Administrator Staff Member Licensed User

    Very soon...
  4. tufanv

    tufanv Expert Licensed User

    Do we have to delete admob entry from manifest editor before adding the firebase admob to manifest ?
    b4aexpress likes this.
  5. Pendrush

    Pendrush Well-Known Member Licensed User

    somed3v3loper and Erel like this.
  6. Erel

    Erel Administrator Staff Member Licensed User

    Note that you can make as many projects that you like in Firebase.
    Pendrush likes this.
  7. Douglas Farias

    Douglas Farias Expert Licensed User

    hi @Erel
    many thx for this lib.

    one question.
    i not tested the lib, because i dont have b4a 6, i m waiting the email :)

    this lib will support native ads for listviews, clv etc..?
    and the video ads too will support?

    thx again.

  8. Erel

    Erel Administrator Staff Member Licensed User

    Currently it only supports banner ads and interstitial ads.

    If anyone likes I can post the source code of this library.
    Ferdari, Douglas Farias and asales like this.
  9. Douglas Farias

    Douglas Farias Expert Licensed User

    erel what the avaible events?

    IAD_AdClosed etc...

    Have event about error? clicked, opened etc...

    the iad here is never ready i need to know why :(

    Edit. i found this
    Sub iad_AdClosed
    'prepare a new ad
    End Sub

    Sub iad_ReceiveAd
    End Sub

    Sub iad_FailedToReceiveAd (ErrorCode As String)
    Log("not Received - " &"Error Code: "&ErrorCode)
    End Sub

    Sub iad_adopened
    End Sub

    The problem now is the error code: 0

    - Make new app intersticial and get the code OK
    - Sync with firebase and put the package name to download the json file OK
    - Put the json file on the app folder OK

    - Download the last sdk, google play services and etc... OK
    - Add the permisions code at manifest OK
    i made all this tutorial.

    - Start the iad OK
    Error Log : Code 0 FAIL

    what can is this error? its new app made only to test, this is not on google play or banned.
    the code and tutorials are ok

    I m reinstaled the google play services again and now its working

    thx again
    Last edited: Jun 10, 2016
  10. Douglas Farias

    Douglas Farias Expert Licensed User

    Just a simple question.
    This lib need this?
    #AdditionalJar: android-support-v4
    Like the old lib?

  11. Erel

    Erel Administrator Staff Member Licensed User

    eps and Douglas Farias like this.
  12. itgirl

    itgirl Active Member Licensed User

    can you plz share the source so maybe we can extend it to support the rest ads?
  13. Erel

    Erel Administrator Staff Member Licensed User

    Attached Files:

    • src.zip
      File size:
      2.5 KB
    koaunglay and itgirl like this.
  14. sorex

    sorex Expert Licensed User

    I upgraded to v6.0
    I added the lib to my additional libs folder
    refreshed the list
    when I select the firebaseadmob library I get what you see in the picture below...

  15. sorex

    sorex Expert Licensed User

    I just read I had to install additional stuff for v6.0, will do that first and give another status later...
  16. sorex

    sorex Expert Licensed User

    Adding these extra libraries solved my problem
  17. sorex

    sorex Expert Licensed User

    first impressions...

    it works ;) well done!

    it's bloated > app went from 1.4Mb to 2.34Mb compared to the old admob+googleplayservices method.

    not sure if we can exclude some of the stuff that's not required when just using the ads part?

    I'm not sure about the benefits of this FireBase thing, maybe it reflects tomorrow when the data from my tests are visible in the reports.
  18. Erel

    Erel Administrator Staff Member Licensed User

    You shouldn't exclude any class as only the components required (based on the Maven dependencies files) are added.
  19. Douglas Farias

    Douglas Farias Expert Licensed User

    Hi @Erel
    i m received this email from google admob, i dont know if cause any changes here.

    AdMob is committed to providing you the most effective monetization solutions. As we innovate, it is important to use the latest technologies to enhance our platform. As part of this move, we will disable the 6.4.1 and earlier versions of Ads SDK for Google mobile on Android on September 15, 2016.
    To ensure your ads run after September 15, 2016, upgrade to the SDK mobile ads Google 7.0.0 or later.
    SDKs ads for the latest Google mobile devices have much more advantages for you:
    Continuous automatic updates. Users receive the changes in Ads SDK for Google mobile on Android continuously through the Google Play services so you can use your time on what's important
    You do not have to spend time updating your applications with the latest versions of the SDK ads whenever it changes
    Users also receive new features and bug fixes through Automatic Updates
    Best user experience. The management of the application updates will be easier for users because some improvements will be received automatically in the background.
    To upgrade your SDK add the latest version of Google Play services (facilities) in your Gradle Build configuration file. For example, see the following addition of v9.0:

    apply plugin: 'com.android.application'
    dependencies {
    Stay tuned for more updates and tips.

    this will change something in this library? or will not change anything?

    ps: google play services now is REV 31

    Last edited: Jul 4, 2016
  20. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    Hi Erel,

    I also received the email from AdMob advising of the impending deprecation of SDK 6.4.1. I have been using the mwAdmobInterstitial2 library for a long time & it works great, however I don't know what version of the AdMob SDK it uses - so I thought I'd switch to AdMob through Firebase. I'm also using the Google Play Services library written by NFOBoy for leaderboards & achievements (I know it's an old library, but it has worked well for me) & now after switching Admob to Firebase, I get the following error when I compile the app:

    I'm guessing that there's some kind of conflict between the version of Google Play Services that Firebase is using & the version (v14 I think) that NFOBoy's library is using?

    - Colin.
Thread Status:
Not open for further replies.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice