Search Unity

Advertisement is not showing on a device.

Discussion in 'Unity Ads & User Acquisition' started by u_rs, Feb 21, 2016.

  1. u_rs

    u_rs

    Joined:
    Jan 5, 2016
    Posts:
    147
    In Unity Editor there are blue screen in place where my ad should be: "Here would be your Ad unit (things seems to be working".
    What I did:
    • added code related to ad to my scripts (with the same app ID as in Unity Ad service),
    • entered link to GooglePlay app page in Unity Ad Service,
    • forced test mode OFF.
    But if I install APK on a device - there are no ad screen (both with debugging mode and with signed APK).
    In Unity Ad Service: I checked my app ID, entered link to google play page with my game. Did I miss something, some step (should I do something on AdMob site, or interact with some advertiser) ?
    See screenshots with Ad Service settings below.
    That's my code related with ad:

    Code (CSharp):
    1. void Start()
    2. {
    3.     Advertisement.Initialize ("1040540", true);
    4.    ...
    5. }
    6.  
    7.     public void Exit()
    8.     {
    9.         StartCoroutine(ShowAd());
    10.         SceneManager.LoadScene ("SelectionMenu");
    11.         ....
    12.     }
    13.  
    14.     IEnumerator ShowAd()
    15.     {
    16.         while (!Advertisement.IsReady ())
    17.         {
    18.             yield return null;
    19.         }
    20.         Advertisement.Show();
    21.     }
     

    Attached Files:

    Last edited: Feb 21, 2016
  2. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    When are you calling Exit() method? Immediately after startup, or when first scene has ended?
     
  3. u_rs

    u_rs

    Joined:
    Jan 5, 2016
    Posts:
    147
    When user exits from a level. It's a method for Exit button.
     
  4. u_rs

    u_rs

    Joined:
    Jan 5, 2016
    Posts:
    147
    Can I add advertisement another way ? May be old way - before Unity Ad Service appeared.
     
    Last edited: Feb 21, 2016
  5. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    Sorry for delay. Works without problems here on my Android device, when using your example code.

    Have you tried without the use of Coroutines in this case? If the ad isn't ready for whatever reason (connectivity, ads disabled on device etc), you would end up in a situation where you just loop forever, or have the Ad shown on some random time later on.

    In this case I would suggest that you just use a normal non-coroutine method, and in case ad isn't available just ignore it. Makes sense?

    -Rasmus
     
  6. u_rs

    u_rs

    Joined:
    Jan 5, 2016
    Posts:
    147
    Last edited: Feb 23, 2016
  7. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    Why does your game require access to storage? Most recent versions of Ads SDK for Android at least doesn't require this permission.

    Which version of Unity/Unity Ads SDK are you using? In case you are not using latest version, can you upgrade it?

    -Rasmus
     
  8. u_rs

    u_rs

    Joined:
    Jan 5, 2016
    Posts:
    147
    I use latest versions. In player settings, install location: I selected auto (I think that's why it asks this permission), do you want me to change it (or how about I'll sent you development build apk) ?
     
  9. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    Please define "latest versions". Which Unity version, and are you using Ads from Asset Store or enabled using Services Window in Unity 5.2 and above?

    Don't think "Install location" should give the app access to local storage.

    -Rasmus
     
  10. u_rs

    u_rs

    Joined:
    Jan 5, 2016
    Posts:
    147
    Unity 5.3.2f1, using Services window
     
  11. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    Something is not correct here. Can you report a bug using the "Help -> Report a bug" menu item from Unity with your project attached and post the bug id here (not the full url)?

    -Rasmus
     
  12. u_rs

    u_rs

    Joined:
    Jan 5, 2016
    Posts:
    147
  13. u_rs

    u_rs

    Joined:
    Jan 5, 2016
    Posts:
    147
    Today I tried to create test app and don't understand why ad is not working at all in it, even in editor.
     

    Attached Files:

  14. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    Seems you are trying to show ad immediately after Advertisement.Initialize() call? Could you try something like the following, to see if ads is being shown?
    And use of Update() here is only for the example purpose, you should put this logic somewhere else.

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Advertisements;
    3.  
    4. public class NewBehaviourScript : MonoBehaviour
    5. {
    6.     bool adsHasBeenShown = false;
    7.  
    8.     void Start ()
    9.     {
    10.         Advertisement.Initialize ("<gameid>", true);
    11.     }
    12.  
    13.     void Update()
    14.     {
    15.         if (!adsHasBeenShown && Advertisement.IsReady ())
    16.         {
    17.             adsHasBeenShown = true;
    18.             Advertisement.Show ();
    19.         }
    20.     }
    21. }
     
  15. u_rs

    u_rs

    Joined:
    Jan 5, 2016
    Posts:
    147
    Now ad works in editor after I put .Show() in button's method. But on a real device still no ad screen. Used development build.
    May be I missing something, as I understand I should do these steps (for testing):
    • create new ad in my page on Unity Ad Service;
    • put Initialize() and Show() in some script with ad ID from Ad Service;
    • check editor shows blue screens for ad;
    • create APK in debug mode, install it;
    After that I should see ad, right ?
     
    Last edited: Feb 26, 2016
  16. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    Yes, that should work. Did you also verify Advertisement.IsReady() before showing .Call() ?

    And if you are using the built-in version of Unity Ads in editor, you don't need to call Initialize(), as this is done automatically by the engine.
     
  17. u_rs

    u_rs

    Joined:
    Jan 5, 2016
    Posts:
    147
    Yes, verified, removed Initialize(), nothing changes.
     
  18. GerardQ

    GerardQ

    Joined:
    Oct 15, 2011
    Posts:
    68
    I have the same issue: Ads working on iOS, but not on Android.
    On iOS, the ads work perfectly and tested on 3 devices.
    The same project on Android with test mode enabled works in the editor and on the device.
    But no ads are showing on any Android devices tested to when testmode is disabled.
     
    Last edited: Mar 13, 2016
  19. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
  20. GerardQ

    GerardQ

    Joined:
    Oct 15, 2011
    Posts:
    68
    Hi, Rasmus

    Thank you for your response on a Sunday.

    How would I implement debugLevel in the script? Can you give me an example?

    Is it:
    Advertisement.debugLevel = Advertisement.debugLevel.Debug ??
     
  21. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    Correct
    Code (CSharp):
    1. Advertisement.debugLevel = Advertisement.DebugLevel.Debug;
    Should be set before call to Initialize()
     
  22. GerardQ

    GerardQ

    Joined:
    Oct 15, 2011
    Posts:
    68
    Ok FYI: When I do it the way I wrote it (wrong case), then everything compiles fine, but the ads don't show and there are no debug output. Casing it the way you did shows the expected logs in the console.

    Now I will work on attaching Monodevelop to the deice for debugging...
     
  23. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    Yes, you need to look in the device logs, i.e. using "adb logcat" on Android. Hope you figure out what the issue is
     
  24. GerardQ

    GerardQ

    Joined:
    Oct 15, 2011
    Posts:
    68
    Ok, sorry I need some help here. How do you specify which device to log with logcat?

    I get "error: more than one device/emulator when trying logcat.

    I tried the ip address, ip address : port, port, 0, 1, 2,

    Ah nevermind. I got it. "logcat -d <IP : port>" works it seems
     
    Last edited: Mar 13, 2016
  25. GerardQ

    GerardQ

    Joined:
    Oct 15, 2011
    Posts:
    68
    Alright. Strangely, with debugging enabled the ads now work on the device.

    Now I will disable debugging options in build settings and try again. ..

    ... Check. Ads now working when build settings are for a normal build with no debugging.

    Now I will comment out the debugLevel line and see it it still works. Could this have been a server side issue?

    ... Check. Ads now working!

    Nothing has changed in my scripts. The only thing I added was the line

    Code (CSharp):
    1. Advertisement.debugLevel = Advertisement.DebugLevel.Debug;
    but then that was commented out.


    so I'm baffled.
     
    Last edited: Mar 13, 2016
  26. GerardQ

    GerardQ

    Joined:
    Oct 15, 2011
    Posts:
    68
    Rasmus,

    It's now working on all my devices with no changes to my code. Were there any updates on your side or could this have been a server issue? And I have another question:

    Does Advertisement.isShowing turn false when the video stops even if the user didn't close the ad window?
    It seems it returns false when the video stops playing, instead of when the user closes the ad.

    I put a delay of a minute or so between ads. Then I call the next ad with:
    Code (CSharp):
    1. if (!Advertisement.isShowing) {
    2.  
    3.         Advertisement.Show();
    4.        
    5. }
    (In my code the time resets regardless of whether the ad is showing or not, so that it won't
    call an ad in the next frame as soon as the player closes the window.)

    I would expect if an ad played and the ad screen sits there with the "X" in the top-left corner, then closing it should go back to the game, correct? But this is not what happens when the ad sat there for long enough - it then goes to the next ad video immediately, which tells me it didn't make isShowing = false

    So how can I detect if the ad is still on the screen even though the video stopped playing?
     
    Last edited: Mar 13, 2016
  27. rasmus-unity

    rasmus-unity

    Moderator

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    Sorry for late reply. I'm not aware that we had any server issues during weekend, so I would have liked to see the logs. If you have the log, you can search "UnityAds"