Search Unity

Admob ads not showing

Discussion in 'Android' started by marciomusa, Dec 6, 2017.

  1. marciomusa

    marciomusa

    Joined:
    Dec 6, 2017
    Posts:
    2
    Hi. I have a problem with Admob. I'm trying to add banner ad in my unity project. In editor, I get "Dummy LoadAd" message on console. However, when I build the project and install my android devices, ads not appearing. My script are below:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using GoogleMobileAds.Api;

    public class Script : MonoBehaviour {

    // Use this for initialization
    void Start()
    {

    showBannerAd();

    }

    private void showBannerAd()
    {
    string adID = "ca-app-pub-4751616916843066/1619794527";

    //***For Testing in the Device***
    AdRequest request = new AdRequest.Builder()
    .AddTestDevice("406328D9316F2877465487ACED46AB78")
    .Build();
    // request.RequestBannerAd(true);
    //***For Production When Submit App***
    //AdRequest request = new AdRequest.Builder().Build();

    BannerView bannerAd = new BannerView(adID, AdSize.SmartBanner, AdPosition.Top);
    bannerAd.LoadAd(request);
    }

    // Update is called once per frame
    void Update()
    {

    }
    }

    I installed tools, extras and all sdk platforms from Android SDK Manager. I tried to click Resolve Client Jars but it didn't solve the problem. I'm using 5.6.4f1 version of Unity.

    How can I solve this problem?

    Thanks.
     
  2. HyenaGamesDev

    HyenaGamesDev

    Joined:
    Aug 4, 2013
    Posts:
    32
    Here is my setup that is working.. This is my first time doing it so i'm no expert.

    Code (csharp):
    1.  
    2. public class AdController : MonoBehaviour {
    3.  
    4.     const string ADMOB_APP_ID = ...;
    5.     const string AD_UNIT_ID = ...;
    6.     const string AD_UNIT_TEST_ID = ...;
    7.     const string ADMOD_APP_TEST_ID = ...;
    8.     private BannerView bannerView;
    9.  
    10.     public void Start()
    11.     {
    12.         MobileAds.Initialize(AD_UNIT_TEST_ID);
    13.         this.RequestBanner();
    14.     }
    15.  
    16.     private void RequestBanner()
    17.     {
    18.         // Create a 320x50 banner at the bottom of the screen.
    19.         bannerView = new BannerView(AD_UNIT_TEST_ID, AdSize.Banner, AdPosition.Bottom);
    20.  
    21.         // Create an empty ad request.
    22.         AdRequest request = new AdRequest.Builder().Build();
    23.  
    24.         // Load the banner with the request.
    25.         bannerView.LoadAd(request);
    26.     }
    27.  
    28.     public void Cleanup()
    29.     {
    30.         bannerView.Destroy();
    31.     }
    32. }
    33.  
    It looks like you might be missing a "MobileAds.Initialize()" with your Ad Id.
     
  3. marciomusa

    marciomusa

    Joined:
    Dec 6, 2017
    Posts:
    2
    Thanks for reply. But problem is not solved. I tried your scripts too, but the result is same. I'm getting

    Dummy .ctor
    Dummy CreateBannerView
    Dummy LoadAd
    Dummy Initialize

    logs, but still ads not displaying when I build the application. Can android sdk cause that problem?
     
    Last edited: Dec 7, 2017
    elaissaouihamza and Yuki1521 like this.
  4. vickyasvijay

    vickyasvijay

    Joined:
    Apr 12, 2018
    Posts:
    1
    same prblm :(
     
  5. moonsdev

    moonsdev

    Joined:
    Jun 20, 2018
    Posts:
    3
    I have the same problem :( my app crashes
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please provide the device logs which should provide more information, such as unhandled exceptions
     
  7. zikardzoo

    zikardzoo

    Joined:
    Sep 14, 2018
    Posts:
    1
    Ok First
    use this script for Testing with interstitial if it work with it then make change to show banner anyway this is the script !

    using UnityEngine;
    using GoogleMobileAds.Api;
    using GoogleMobileAds;

    public class AdmobManager : MonoBehaviour {


    private InterstitialAd interstitial;

    string AppId = "your App ID";

    void Start()
    {
    MobileAds.Initialize(AppId);
    RequestInterstitial();
    }
    public void RequestInterstitial()
    {
    #if UNITY_ANDROID
    string adUnitId = "Your interstitial ID for android";
    #elif UNITY_IPHONE
    string adUnitId = "Your interstitial ID for IOS";
    #else
    string adUnitId = "unexpected_platform";
    #endif

    // Initialize an InterstitialAd.
    interstitial = new InterstitialAd(adUnitId);
    // Create an empty ad request.
    AdRequest request = new AdRequest.Builder().Build();
    // Load the interstitial with the request.
    interstitial.LoadAd(request);
    }
    public void GameOver()
    {
    if (interstitial.IsLoaded())
    {
    interstitial.Show();
    }
    }
    }
    Step 2 : Make sure to call the game GameOver() function in your game after player death for exemple
    Step 3 : Make sure to have All those logs on the console
    Dummy .ctor
    Dummy Initialize
    Dummy .ctor
    Dummy CreateInterstitialAd
    Dummy LoadAd
    Dummy IsLoaded
    Dummy ShowInterstitial
    if you get all of this and ads still not showing (wich was my case) :
    - Make sure that your SDK tools on the android studio are Updated
    - then you have to use those setting on your Player Build Setting (it took me 3 weeks to find this T.T)

    help.jpg
    help2.jpg
     
    alibabaliyev likes this.
  8. alibabaliyev

    alibabaliyev

    Joined:
    Feb 27, 2017
    Posts:
    1
    Thanks for help. I look for 2 weeks
     
  9. andreystarenky

    andreystarenky

    Joined:
    Jul 31, 2019
    Posts:
    1
    Hey there! If anyone is still looking for help I spent 4 hours trying to fix it and all it took was one line. The AdMob documentation was simply missing "this.bannerView.Show();" you may need to delay it however to make sure the add has loaded.
     
  10. clamum

    clamum

    Joined:
    May 14, 2017
    Posts:
    61
    ARGH man I thought this would've fixed my problem but it didn't. :(

    I put the bannerView.Show() call after all my other code, after the "bannerView.loadAd(request)" line, as well as in my "HandleOnAdLoaded" event handler method.

    DANG IT. Well thanks for your reply anyway man.
     
  11. NotNew

    NotNew

    Joined:
    Jan 24, 2020
    Posts:
    3
    Here I have the same problem as you guys... Even test ads are not appearing...
     
    hendryshaikh2004 likes this.
  12. NotNew

    NotNew

    Joined:
    Jan 24, 2020
    Posts:
    3
    Okay, I've found some solution :
    If you still can't see your test-ads , go to Assets -> External Dependency Manager -> Android Resolver -> Force Resolve.
    If you have an error during resolving (like I did), read what it says and do what you need to do :
    In my example I need to go to
    Project Settings -> Player -> Publishing Settings and under Build section check Custom Base Gradle Template.
    Remeber that you need to wait a little bit - your test ad needs some time to load.

    Hope that it'll help, if not, keep searching! :)

    Edit : Checked if call of Show() method is needed (Banner, test ad) - it's not. Pretty weird, because it exists, but admob documentation doesn't mention it...
     
    Last edited: Sep 22, 2020
  13. ak_bhange

    ak_bhange

    Joined:
    Aug 3, 2016
    Posts:
    1
    in my case test ads are showing properly but real ads are not showing. Now It's been 7+ days I've created those ads and I'm not getting ad filled. so I created house ads but those are also not getting filled. Ad requests are 0. that's weird If my implementation is correct then why ad request is not reaching to admob
     
    elaissaouihamza likes this.
  14. florinel2102

    florinel2102

    Joined:
    May 21, 2019
    Posts:
    76
    Hi guys , I had the same problem the testing ads were displayed , but real ads were not displayed . In this case , go to ad mob account and verify your ad mob account . To verify your account go to dashboard and click on payments and configure it . After your ad mob account will be verified by google your ads will be served / displayed .
     
    ozeol, clamum and XazeRekt like this.
  15. raoabdulmannan

    raoabdulmannan

    Joined:
    Oct 22, 2020
    Posts:
    1
    I faced the same issue and turns out my admob account payment was not set. So all I did is setup payments and on admob payment page, allowed the cookies and then payment was setup.
     
    clamum likes this.
  16. medyn

    medyn

    Joined:
    Jan 13, 2021
    Posts:
    1
    Same here, did you got it to work?
    I really need help
     
  17. IT_Allen

    IT_Allen

    Joined:
    Jul 2, 2021
    Posts:
    1
    Nothing works :(
     
  18. ozeol

    ozeol

    Joined:
    Dec 31, 2020
    Posts:
    5
    Any luck? My admob account is linked to the app in play store, status "ready", added in the real ad unit ID, test ad showing in unity, waited a week...

    result: no real ads
     
    hamzaelaissaoui likes this.
  19. Developbyirfan

    Developbyirfan

    Joined:
    Jan 19, 2023
    Posts:
    1
    I'm facing the same issue. did you manage to solve it or not?
     
  20. Sukrojan

    Sukrojan

    Joined:
    Feb 18, 2023
    Posts:
    1
    Did you solve? it I am facing the same problem