Unity: Test Ads Wont show up HELP!

1,611 views
Skip to first unread message

Fuzzytutor FREE online Learning

unread,
May 23, 2019, 12:00:05 PM5/23/19
to Google Mobile Ads SDK Developers
Test ads wont show up on my Android Device I have the Google play services and the Google Repository installed with sdkmanager and here is my 

I don't get any errors it just dosent display the test ads. What am I Missing? please help.


AdManager Script:

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

public class AddScript : MonoBehaviour
{
    private string AppID = "ca-app-pub-xxxxx~xxxxxx";
    public BannerView bannerAD;
    // Start is called before the first frame update
    void Start()
    {
        string appId = AppID;
        //Initialize Ads SDK
        MobileAds.Initialize(appId);
        this.RequestBanner();
        this.ShowBanner();
    }
    private void RequestBanner()
    {
        string adUnitId = "ca - app - pub - 3940256099942544 / 6300978111";
        // Create a 320x50 banner at the top of the screen.
        bannerAD = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom);
        // Create an empty ad request.
        AdRequest request = new AdRequest.Builder().Build();
        // Load the banner with the request.
        bannerAD.LoadAd(request);
    }
    public void ShowBanner()
    {
        bannerAD.Show();
    }
}

Mobile Ads SDK Forum Advisor Prod

unread,
May 23, 2019, 3:15:23 PM5/23/19
to nauti...@gmail.com, google-adm...@googlegroups.com
Hello there,

Thanks for reaching out to us.  It looks like you are trying to make an AdRequest and then immediately show the BannerAd. You need to wait for the ad to be loaded before you can show the BannerAd. You can try with our sample app and let us know if you are able to fetch the ad. 

Regards,
Deepika Uragayala
Mobile Ads SDK Team

ref:_00D1U1174p._5001UAqRD0:ref

Fuzzytutor FREE online Learning

unread,
May 23, 2019, 7:32:58 PM5/23/19
to Google Mobile Ads SDK Developers
I adjusted my script to show the interstitial ad on the next scene and in the editor it says dummycreateinterstitial and dummyloadad then on the secnd scene it says dummy showinterstitial

but on the test device nothing shows up?

here's the script:

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

public class AddScript : MonoBehaviour
{
    private string AppID = "ca-app-pub-9425188595068192~6403723376";

    private BannerView bannerAD;
    public InterstitialAd interAD;


    // Start is called before the first frame update
    void Start()
    {
        string appId = AppID;

        //Initialize Ads SDK
        MobileAds.Initialize(appId);
        RequestInterstitial();
        RequestBanner();
    }

    private void OnLevelWasLoaded(int level)
    {
        if(level == 1)
        {
            ShowInterstitial();
        }
    }

    private void RequestInterstitial()
    {
#if UNITY_ANDROID
        string adUnitId = "ca-app-pub-3940256099942544/1033173712";
#elif UNITY_IPHONE
        string adUnitId = "ca-app-pub-3940256099942544/4411468910";
#else
        string adUnitId = "unexpected_platform";
#endif

        // Initialize an InterstitialAd.
        this.interAD = new InterstitialAd(adUnitId);

        // Create an empty ad request.
        AdRequest request = new AdRequest.Builder().AddTestDevice(SystemInfo.deviceUniqueIdentifier).Build();

        // Called when an ad request has successfully loaded.
        interAD.OnAdLoaded += HandleOnAdLoaded;
        // Called when an ad request failed to load.
        interAD.OnAdFailedToLoad += HandleOnAdFailedToLoad;

        // Load the interstitial with the request.
        this.interAD.LoadAd(request);
    }

    private void ShowInterstitial()
    {
        if (this.interAD.IsLoaded())
        {
            this.interAD.Show();
        }
        else
        {
            MonoBehaviour.print("Interstitial is not ready yet");

        }
    }


    private void RequestBanner()
    {
        string adUnitId = "ca-app-pub-3940256099942544/6300978111";

        // Create a 320x50 banner at the top of the screen.
        bannerAD = new BannerView(adUnitId, AdSize.Banner, AdPosition.Bottom);

        // Create an empty ad request.
        AdRequest request = new AdRequest.Builder().Build();

        // Load the banner with the request.
        bannerAD.LoadAd(request);

    }

    public void HandleOnAdLoaded(object sender, EventArgs args)
    {
        MonoBehaviour.print("HandleAdLoaded event received");
    }

    public void HandleOnAdFailedToLoad(object sender, AdFailedToLoadEventArgs args)
    {
        MonoBehaviour.print("HandleFailedToReceiveAd event received with message: " + args.Message);
        RequestInterstitial();
    }
}

Mobile Ads SDK Forum Advisor Prod

unread,
May 24, 2019, 3:38:07 PM5/24/19
to nauti...@gmail.com, google-adm...@googlegroups.com
Hello there,

Can you connect your device and open Android Studio and check the logs when you are trying to run it? And check whether any error is being thrown by the SDK and then let us know. This will help you debug this quickly. You can also send us Charles logs (see this link to get started) for us to look into is.



Regards,
Deepika Uragayala
Mobile Ads SDK Team



ref:_00D1U1174p._5001UAqRD0:ref

Fuzzytutor FREE online Learning

unread,
May 25, 2019, 8:14:36 PM5/25/19
to Google Mobile Ads SDK Developers
Ok When I run my apk in android studi Emulator the logCat 

says:

2019-05-25 19:09:43.685 6335-6351/com.FunStuffGames.Bubbles E/SchedPolicy: set_timerslack_ns write failed: Operation not permitted

AND:

 2019-05-25 19:09:49.741 6335-6351/com.FunStuffGames.Bubbles E/Unity: AndroidJavaException: java.lang.ClassNotFoundException: com.google.android.gms.ads.MobileAds
    java.lang.ClassNotFoundException: com.google.android.gms.ads.MobileAds
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:453)
        at java.lang.Class.forName(Class.java:378)
        at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
        at com.unity3d.player.UnityPlayer.c(Unknown Source:0)
        at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:88)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:193)
        at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.ads.MobileAds" on path: DexPathList[[zip file "/data/app/com.FunStuffGames.Bubbles-5zLeETmohFirbifZPKLCUA==/base.apk"],nativeLibraryDirectories=[/data/app/com.FunStuffGames.Bubbles-5zLeETmohFirbifZPKLCUA==/lib/x86, /data/app/com.FunStuffGames.Bubbles-5zLeETmohFirbifZPKLCUA==/base.apk!

Fuzzytutor FREE online Learning

unread,
May 25, 2019, 8:19:23 PM5/25/19
to google-adm...@googlegroups.com
and I try to Resolve Android Dependencies I get this ERROR:

InvalidOperationException: StandardIn has not been redirected.
System.Diagnostics.Process.get_StandardInput () (at <c9226b2f33b7421e85bb391f94075e49>:0)
(wrapper remoting-invoke-with-check) System.Diagnostics.Process.get_StandardInput()
GooglePlayServices.CommandLine.RunViaShell (System.String toolPath, System.String arguments, System.String workingDirectory, System.Collections.Generic.Dictionary`2[TKey,TValue] envVars, GooglePlayServices.CommandLine+IOHandler ioHandler, System.Boolean useShellExecution, System.Boolean stdoutRedirectionInShellMode) (at /usr/local/google/home/cleoschneider/google-play-resolver/unity-jar-resolver/source/PlayServicesResolver/src/CommandLine.cs:604)
GooglePlayServices.CommandLine.Run (System.String toolPath, System.String arguments, System.String workingDirectory, System.Collections.Generic.Dictionary`2[TKey,TValue] envVars, GooglePlayServices.CommandLine+IOHandler ioHandler) (at /usr/local/google/home/cleoschneider/google-play-resolver/unity-jar-resolver/source/PlayServicesResolver/src/CommandLine.cs:510)
GooglePlayServices.CommandLine+<RunAsync>c__AnonStorey1.<>m__1 () (at /usr/local/google/home/cleoschneider/google-play-resolver/unity-jar-resolver/source/PlayServicesResolver/src/CommandLine.cs:134)
System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state) (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
System.Threading.ThreadHelper.ThreadStart () (at <1f0c1ef1ad524c38bbc5536809c46b48>:0)
UnityEngine.UnhandledExceptionHandler:<RegisterUECatcher>m__0(Object, UnhandledExceptionEventArgs)


and the resolve window pops and stays on %0 for hours and nothing happens.

Mobile Ads SDK Forum Advisor Prod

unread,
May 27, 2019, 1:43:47 AM5/27/19
to nauti...@gmail.com, google-adm...@googlegroups.com
Hi there,

I am Deepika's colleague, Ziv, and I am here to help.

Could you provide us with a copy of your sample project (that shows the reproducible errors) using the Reply privately to author option so that I can help in investigating the issues?

Regards,
Ziv Yves Sanchez

Fuzzytutor FREE online Learning

unread,
May 27, 2019, 7:32:05 PM5/27/19
to Google Mobile Ads SDK Developers
I can't send a zip and when i try to send the unity project it says to many attachments?

is there any way i can get in touch with someone through a live chat or something to sort this out? Thanks!

Mobile Ads SDK Forum Advisor Prod

unread,
May 27, 2019, 9:14:41 PM5/27/19
to nauti...@gmail.com, google-adm...@googlegroups.com
Hi there,

You can send the sample project via Google Drive. Don't forget to use the Reply privately to author option since this will be sensitive data.

Fuzzytutor FREE online Learning

unread,
May 28, 2019, 12:51:05 PM5/28/19
to Google Mobile Ads SDK Developers
I sent a private reply with the link the project should be called "project name".rar I had to zip it to upload.

Mobile Ads SDK Forum Advisor Prod

unread,
May 28, 2019, 9:28:38 PM5/28/19
to nauti...@gmail.com, google-adm...@googlegroups.com
Hi there,

Thank you for providing your sample project in private.

I was able to test your project both in the Unity editor and on a test device, and can confirm that I was getting test ads from it. For your concern about the Play Services Resolver, you can try doing the instructions below and see if it'll fix it:
  1. Go to File -> Build Settings, then switch to the Android platform (see attached image "1.png").
  2. Go to Assets -> Play Services Resolver -> Android Resolver, then click on Force Resolve.
As for your concern about not seeing test ads: after I resolved the dependencies and built the project on a test device, I was able to immediately get test ads from it. Kindly see attached images.
You may refer to our guides on banner and interstitial ads, as well as our sample project, to help in your implementation of the AdMob SDK.
1.png
Screenshot_20190529-090057.png
Screenshot_20190529-090028.png

Fuzzytutor FREE online Learning

unread,
May 29, 2019, 12:18:15 PM5/29/19
to Google Mobile Ads SDK Developers
I am already switched to Android Platform and it still cant resolve, it gives me the same SntandardIn has not been redirected error and Does not load anything. i have no idea what is wrong

Fuzzytutor FREE online Learning

unread,
May 29, 2019, 12:30:34 PM5/29/19
to google-adm...@googlegroups.com
Here's a screenshot of what I'm getting (it just stays like this indefinitely)
ScreenShot_ErrorResolving.png

Fuzzytutor FREE online Learning

unread,
May 29, 2019, 1:28:47 PM5/29/19
to google-adm...@googlegroups.com
Here is screen shots of my SDK/JDK and the error I have tried with the sdk/jdk that came with unity and tried installing sdk/jdk seperetly both give the same error
I have set the ANDROID_HOME and the JAVA_HOME and included the %ANDROID_HOME%\tools,platform-tools,tools\bin,extras\google\googleplayservices and extras\google\m2repository in the path I just can't figure out what the heck is missing?
Untitled.png
Untitled2.png
Untitled3.png
Untitled34.png

Fuzzytutor FREE online Learning

unread,
May 29, 2019, 1:36:49 PM5/29/19
to google-adm...@googlegroups.com
if I resolve instead of Force resolve I get these two new errors: screenshots attached
and the adb.exe is in the sdk\platform-tools directory so I don't understand that error either(referring to the screenshots)
ScreenShot_ErrorResolving.png
Untitled.png

Mobile Ads SDK Forum Advisor Prod

unread,
May 29, 2019, 7:24:17 PM5/29/19
to nauti...@gmail.com, google-adm...@googlegroups.com
Hi there,

Thank you for providing additional valuable information.

It seems that the error you are experiencing stems from the fact that you have non-standard characters in your file paths (in particular, the apostrophe in Shadrick's Office). Could you try moving the entire Unity project (and other related folders, like the Android SDK and the JDK) off C:/Users/Shadrick's Office to somewhere else, and see if it'll work?

Fuzzytutor FREE online Learning

unread,
May 30, 2019, 10:45:22 AM5/30/19
to Google Mobile Ads SDK Developers
Hi thanks for responding, but just to clarify is the apostrophe the only problem or is the space an issue too (eg. is Program Files an ok place) Thanks!

Fuzzytutor FREE online Learning

unread,
May 30, 2019, 1:08:46 PM5/30/19
to Google Mobile Ads SDK Developers
Hi I have moved my files to the C drive and now  did a Resolve and it worked but it still does not show any ads, I must still be missing something?

On Wednesday, May 29, 2019 at 6:24:17 PM UTC-5, mobileadssdkforumadvisor wrote:

Fuzzytutor FREE online Learning

unread,
May 30, 2019, 1:36:29 PM5/30/19
to Google Mobile Ads SDK Developers
When I run it in the android studio emulator I get this error when I tries to load the interstitial 

2019-05-30 12:33:27.264 10946-10965/? E/Unity: NullReferenceException: Object reference not set to an instance of an object
      at AddScript.ShowInterstitial () [0x00000] in <67796f3bccd54853b56f7c2af29ca052>:0
      at AddScript.OnLevelWasLoaded (System.Int32 level) [0x00004] in <67796f3bccd54853b56f7c2af29ca052>:0
    
    (Filename: <67796f3bccd54853b56f7c2af29ca052> Line: 0)

but no errors about the banner wich still wont show (again it has successfully resolved the dependencies)

Fuzzytutor FREE online Learning

unread,
May 30, 2019, 5:47:18 PM5/30/19
to google-adm...@googlegroups.com
Hi Thanks So mUch for your Help it seems to be working now Last two questions though if I play my own game will I get suspended from Admob (assuming I don't click on the ads just see them on the screen)? and how long should I need to wait to start seeing the real ads? Thanks A Million!

Mobile Ads SDK Forum Advisor Prod

unread,
May 30, 2019, 8:33:07 PM5/30/19
to nauti...@gmail.com, google-adm...@googlegroups.com
Hi there,

Glad to hear your project's working!

I recommend using test ads if you will be playing your game in a test environment for a long period of time. However, it should be fine to use live ads on your test environment just to check if they'd appear already (though it's better not to click on them regardless).

You can expect real ads to show after a few days of completing the setup of your AdMob account (your billing information and address verification in particular). Kindly note however that showing live ads on an unpublished app will negatively affect their fill rate. Publishing your app should improve said fill rate.
Reply all
Reply to author
Forward
0 new messages