• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
Question by jc-drile77 · Jan 05, 2016 at 11:40 PM · androidunity 5adsadmobandroidplugin

adMob ads are black

Hi, When I run my adMob script (the official) on my Android devide as a tester device it runs fine, it shows the usual adMob test ad. But when I try to run it as "regular user" it shows a black ad (interstitial) the banner doesnt even show, Help? I atach an image with the black ad and the code im using. Yes it´s the demoScript with the GUI and everything, i tried to stay as close to the original as possible in order to track down the issue, I run this on an empty scene. Im using latest plugin, sdk and Unity version.

 using System;
 using UnityEngine;
 using GoogleMobileAds;
 using GoogleMobileAds.Api;
 
 
 // Example script showing how to invoke the Google Mobile Ads Unity plugin.
 public class GoogleMobileAdsDemoScript : MonoBehaviour
 {
 
     private BannerView bannerView;
     private InterstitialAd interstitial;
     private static string outputMessage = "";
 
     public static string OutputMessage
     {
         set { outputMessage = value; }
     }
 
     void OnGUI()
     {
         // Puts some basic buttons onto the screen.
         GUI.skin.button.fontSize = (int) (0.05f * Screen.height);
         GUI.skin.label.fontSize = (int) (0.025f * Screen.height);
 
         Rect requestBannerRect = new Rect(0.1f * Screen.width, 0.05f * Screen.height,
                                    0.8f * Screen.width, 0.1f * Screen.height);
         if (GUI.Button(requestBannerRect, "Request Banner"))
         {
             RequestBanner();
         }
 
         Rect showBannerRect = new Rect(0.1f * Screen.width, 0.175f * Screen.height,
                                        0.8f * Screen.width, 0.1f * Screen.height);
         if (GUI.Button(showBannerRect, "Show Banner"))
         {
             bannerView.Show();
         }
 
         Rect hideBannerRect = new Rect(0.1f * Screen.width, 0.3f * Screen.height,
                                        0.8f * Screen.width, 0.1f * Screen.height);
         if (GUI.Button(hideBannerRect, "Hide Banner"))
         {
             bannerView.Hide();
         }
 
         Rect destroyBannerRect = new Rect(0.1f * Screen.width, 0.425f * Screen.height,
                                           0.8f * Screen.width, 0.1f * Screen.height);
         if (GUI.Button(destroyBannerRect, "Destroy Banner"))
         {
             bannerView.Destroy();
         }
 
         Rect requestInterstitialRect = new Rect(0.1f * Screen.width, 0.55f * Screen.height,
                                                 0.8f * Screen.width, 0.1f * Screen.height);
         if (GUI.Button(requestInterstitialRect, "Request Interstitial"))
         {
             RequestInterstitial();
         }
 
         Rect showInterstitialRect = new Rect(0.1f * Screen.width, 0.675f * Screen.height,
                                              0.8f * Screen.width, 0.1f * Screen.height);
         if (GUI.Button(showInterstitialRect, "Show Interstitial"))
         {
             ShowInterstitial();
         }
 
         Rect destroyInterstitialRect = new Rect(0.1f * Screen.width, 0.8f * Screen.height,
                                                 0.8f * Screen.width, 0.1f * Screen.height);
         if (GUI.Button(destroyInterstitialRect, "Destroy Interstitial"))
         {
             interstitial.Destroy();
         }
 
         Rect textOutputRect = new Rect(0.1f * Screen.width, 0.925f * Screen.height,
                                    0.8f * Screen.width, 0.05f * Screen.height);
         GUI.Label(textOutputRect, outputMessage);
     }
 
     private void RequestBanner()
     {
         #if UNITY_EDITOR
             string adUnitId = "unused";
 #elif UNITY_ANDROID
             string adUnitId = "ca-app-pub-unitID";
 #elif UNITY_IPHONE
             string adUnitId = "INSERT_IOS_BANNER_AD_UNIT_ID_HERE";
 #else
             string adUnitId = "unexpected_platform";
 #endif
 
         // Create a 320x50 banner at the top of the screen.
         bannerView = new BannerView(adUnitId, AdSize.SmartBanner, AdPosition.Top);
         // Register for ad events.
         bannerView.AdLoaded += HandleAdLoaded;
         bannerView.AdFailedToLoad += HandleAdFailedToLoad;
         bannerView.AdOpened += HandleAdOpened;
         bannerView.AdClosing += HandleAdClosing;
         bannerView.AdClosed += HandleAdClosed;
         bannerView.AdLeftApplication += HandleAdLeftApplication;
         // Load a banner ad.
         bannerView.LoadAd(createAdRequest());
     }
 
     private void RequestInterstitial()
     {
         #if UNITY_EDITOR
             string adUnitId = "unused";
 #elif UNITY_ANDROID
             string adUnitId = "ca-app-pub-unitID";
 #elif UNITY_IPHONE
             string adUnitId = "INSERT_IOS_INTERSTITIAL_AD_UNIT_ID_HERE";
 #else
             string adUnitId = "unexpected_platform";
 #endif
 
         // Create an interstitial.
         interstitial = new InterstitialAd(adUnitId);
         // Register for ad events.
         interstitial.AdLoaded += HandleInterstitialLoaded;
         interstitial.AdFailedToLoad += HandleInterstitialFailedToLoad;
         interstitial.AdOpened += HandleInterstitialOpened;
         interstitial.AdClosing += HandleInterstitialClosing;
         interstitial.AdClosed += HandleInterstitialClosed;
         interstitial.AdLeftApplication += HandleInterstitialLeftApplication;
         // Load an interstitial ad.
         interstitial.LoadAd(createAdRequest());
     }
 
     // Returns an ad request with custom ad targeting.
     private AdRequest createAdRequest()
     {
         return new AdRequest.Builder()
             .AddTestDevice(AdRequest.TestDeviceSimulator)
                  .AddTestDevice("0123456789ABCDEF0123456789ABCDEF")
                  .AddKeyword("game")
                  .TagForChildDirectedTreatment(false)
                  .Build();
 
     }
 
     private void ShowInterstitial()
     {
         if (interstitial.IsLoaded())
         {
             interstitial.Show();
         }
         else
         {
             print("Interstitial is not ready yet.");
         }
     }
 
     #region Banner callback handlers
 
     public void HandleAdLoaded(object sender, EventArgs args)
     {
         print("HandleAdLoaded event received.");
     }
 
     public void HandleAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
     {
         print("HandleFailedToReceiveAd event received with message: " + args.Message);
     }
 
     public void HandleAdOpened(object sender, EventArgs args)
     {
         print("HandleAdOpened event received");
     }
 
     void HandleAdClosing(object sender, EventArgs args)
     {
         print("HandleAdClosing event received");
     }
 
     public void HandleAdClosed(object sender, EventArgs args)
     {
         print("HandleAdClosed event received");
     }
 
     public void HandleAdLeftApplication(object sender, EventArgs args)
     {
         print("HandleAdLeftApplication event received");
     }
 
     #endregion
 
     #region Interstitial callback handlers
 
     public void HandleInterstitialLoaded(object sender, EventArgs args)
     {
         print("HandleInterstitialLoaded event received.");
     }
 
     public void HandleInterstitialFailedToLoad(object sender, AdFailedToLoadEventArgs args)
     {
         print("HandleInterstitialFailedToLoad event received with message: " + args.Message);
     }
 
     public void HandleInterstitialOpened(object sender, EventArgs args)
     {
         print("HandleInterstitialOpened event received");
     }
 
     void HandleInterstitialClosing(object sender, EventArgs args)
     {
         print("HandleInterstitialClosing event received");
     }
 
     public void HandleInterstitialClosed(object sender, EventArgs args)
     {
         print("HandleInterstitialClosed event received");
     }
 
     public void HandleInterstitialLeftApplication(object sender, EventArgs args)
     {
         print("HandleInterstitialLeftApplication event received");
     }
 
     #endregion
 }
 

alt text

screenshot-2016-01-06-00-30-361.png (12.1 kB)
Comment

People who like this

0 Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image yigites · Jan 06, 2016 at 03:25 AM 0
Share

I have the same issue recently. I use prime31 and their example ad ids works normally. But when i use newly created ad id, it shows black screen. It may be related to new ads has video or something.

2 Replies

· Add your reply
  • Sort: 
avatar image
Best Answer

Answer by jc-drile77 · Jan 06, 2016 at 01:25 PM

Problem solved, the issue was on the latest release of the plugin (2.3.1), downloaded 2.2.1 and everything seems to be working fine. IAP ads may be the problem but I wont try to fix it as I implementing my own solution for that its quite easy :)

Comment

People who like this

0 Show 0 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image

Answer by dignitygames · Apr 06, 2016 at 06:38 PM

Hi i have the same issue. Could you please explain how you sorted it out? i am new so i don't quite understand what you mean in your answer.

Thanks

Comment

People who like this

0 Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image yigites · Apr 06, 2016 at 07:17 PM 0
Share

I figured that i was using latest plugin but not latest admob sdk. You need to use correct sdk version that plugin uses. (this is for ios only, android works normally) i mean sdk is framework

avatar image dignitygames yigites · Apr 06, 2016 at 07:20 PM 0
Share

ok i basically what i done was, i added the admob test id and compiled my game and it worked fine. Then i added my interstitial id and compiled my game again and for some weird reason it was work. I have no idea why. It happened before also but i want to know why.

Also would i need to update my game again in order for it to work for the users?

Thanks

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

53 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

I am using admob with unity. But the ads are not getting loaded. My script is bellow.. Am i missing something? Or i have to do something else? 0 Answers

Unity Google AdMob Banner 2 Answers

how to fix admob Enable checkbox not showing ? 1 Answer

admob banner ad not showing 0 Answers

Admob impressions are not counted 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges