Unity ads 3.7.3: rewarded video ad not triggering OnUnityAdsShowComplete

Hi,

I’m testing UnityAds with the code from this example.
https://unityads.unity3d.com/help/unity/integration-guide-unity

Unity version: 2018.4.22
Unity ads version: 3.7.3
Platform: Android
Ads setting : Test Mode Enable
All the code is exactly the same as in example.

Initalizing & Ads load are working properly as it should be. I got the following log from console.
“Unity Ads initialization complete.”
“Loading Ad: Rewarded_Android”
“Ad Loaded: Rewarded_Android”

but after Advertisement.Show had been called, the test ad appears.
but after closing it, OnUnityAdsShowComplete doesn’t trigger.
(I also add Debug.Log at start of the function to check this)

when I call Advertisement.Show again, I got error in console.
“Error showing Ad Unit Rewarded_Android: NOT_READY - Placement Rewarded_Android is not ready”
which means OnUnityAdsFailedToLoad was triggered.

Could you please suggest what I did wrong?
Thanks in advance & best regard

1 Like

Hi,

We are experiencing the same issue. Something seems to be wrong with the test ads. OnUnityAdsShowStart works as it’s supposed to but OnUnityAdsShowComplete never triggers. The only difference in our configuration is that our Unity version is 2018.4.36f1 but everything else matches.

2 Likes

I have the exact same problem with my project
Unity version: 2020.3.14f1
Unity ads version: 3.7.3
the problem persist even if I use the old “void HandleShowResult(ShowResult result)” method, not just the new OnUnityAdsShowComplete() if I thy to use in the new suggeste implementation
“void HandleShowResult(ShowResult result)” using no listeners still works

2 Likes

I have same issue too.
Unity version : 2021.1.12f
Unity ads : 3.7.3

Some ads have this problem
ad type : playable

1 Like

My work around for now is, roll back Unity Ads to version 3.6.1, and use old callback method “OnUnityAdsDidFinish” instead of “OnUnityAdsShowComplete”

so I supposed 3.7.3 still have some bug.

funny thing is the old deprecated code stll works even on advertisement 3.7.3
void ShowAd()
{
ShowOptions options = new ShowOptions();

options.resultCallback = HandleShowResult;

Advertisement.Show(adsPlacementId, options);
}

void HandleShowResult(ShowResult result)
{
if (result == ShowResult.Finished)
{
Debug.Log(“Video completed - Offer a reward to the player”);
AddDonut();
#if UNITY_ANALYTICS
AnalyticsEvent.AdComplete(adsRewarded, adsNetwork, adsPlacementId);
#endif
}
else if (result == ShowResult.Skipped)
{
//Debug.LogWarning(“Video was skipped - Do NOT reward the player”);
#if UNITY_ANALYTICS
AnalyticsEvent.AdSkip(adsRewarded, adsNetwork, adsPlacementId);
#endif
}
else if (result == ShowResult.Failed)
{
//Debug.LogError(“meh Video failed to show”);
#if UNITY_ANALYTICS
AnalyticsEvent.AdSkip(adsRewarded, adsNetwork, adsPlacementId, new Dictionary<string, object> {
{ “error”, “failed” }
});
#endif
}
}

We just noticed that the issue seems to only occur in editor. If we make a build and run it on an android device everything works as expected.

2 Likes

In my case error is presnt in both the editor and on build

Update: updated to 3.7.5 and the problem still persist

1 Like

Hi,

For your problem, I have tested with UnityAds SDK 3.7.5. May I know whether this happened each time? It works well on my side.
Here are some codes you may need to pay attention to:
Advertisement.Initialize(androidID, testMode, true); //The last true is for EnablePerPlacement. Without it, you may load ads failed.
Advertisement.Show(mySurfacingId2, this); //You need to set up listener to catch the callback.

I hope this will help.

2 Likes

the problem seems fixed in the builld after re-enabling EnablePerPlacement (not sure why one would turn it off), but it still persist in the editor. It’s a bit annoying because I have to build every time I have some changes I want to verify

i have the same bug. 2020.3.14 and sdk 3.7.5. “OnUnityAdsShowComplete” dont work.
There may be something wrong with the test ads. Instead of a video, it shows a static image. Perhaps because of this, it does not work.
OnUnityAdsShowStart - work
OnUnityAdsDidStart - work
OnUnityAdsDidFinish - work.

Hi,

May I confirm with you whether you use “IUnityAdsShowListener” interface, and set it to your SDK(Advertisement.Show(placementId, this); )?

7424537--908732--init.PNG
7424537--908729--show.PNG
7424537--908738--adsshow.PNG
7424537--908741--finish.PNG

Hi Termobudka,

I understand your problem. In the editor, there is only a fake ad, and it won’t fire the onComplete callback. If you want to test it, you need to build it as a mobile version and run it on a real device or simulator. It should work.

2 Likes

I thought so, that the test ad in the editor, does not call OnComplete. in the mobile all work good.
it would be nice if the editor also worked.

1 Like

I also have the same problem on Unity 2020.3.14f1 and SDK 3.7.5, wheter I run it from the editor or my Android device, the OnUnityAdsShowComplete isn’t triggering.

Hi Winnie,

May I check whether you use the “IUnityAdsShowListener” interface and set it to your SDK(Advertisement.Show(placementId, this); )? Only this setting will trigger the “OnUnityAdsShowComplete”. What’s more, it will not be triggered in the Editor, but only on the real phone.

If you still meet this problem, may you send us some sample codes of your project?

1 Like

Yes of course, thanks a lot LIU. I’m loading the Ad through the ShowAd() method with the continueButton, it’s linked via the Editor in case you require that information.

using UnityEngine;
using UnityEngine.Advertisements;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class RewardedAd : MonoBehaviour, IUnityAdsInitializationListener, IUnityAdsLoadListener, IUnityAdsShowListener
{

#if UNITY_IOS
    private string gameId = "4268458";
#elif UNITY_ANDROID
    private string gameId = "4268459";
#endif

    bool testMode = true;

    private string adUnitId;
    public GameMaster gm;
    public Button continueButton;

    void Start()
    {
        adUnitId = "Rewarded_Android";

        Advertisement.Initialize(gameId, testMode, true, this);
    }

    public void LoadAd()
    {
        Debug.Log("Loading Ad");
        Advertisement.Load(adUnitId, this);
    }

    public void ShowAd()
    {
        Debug.Log("Showing Ad");
        Advertisement.Show(adUnitId, this);
    }
    public void OnInitializationComplete()
    {
        Debug.Log("Unity Ads initialization complete.");
        LoadAd();
    }

    public void OnInitializationFailed(UnityAdsInitializationError error, string message)
    {
        Debug.Log($"Unity Ads Initialization Failed: {error.ToString()} - {message}");
        SceneManager.LoadScene(SceneManager.GetActiveScene().name, LoadSceneMode.Single);
    }

    // Implement Load Listener and Show Listener interface methods:
    public void OnUnityAdsAdLoaded(string adUnitId)
    {
        Debug.Log("Ad Loaded successfully");
        // Optionally execute code if the Ad Unit successfully loads content.
        continueButton.interactable = true;
    }

    public void OnUnityAdsFailedToLoad(string adUnitId, UnityAdsLoadError error, string message)
    {
      
        Debug.Log($"Error loading Ad Unit: {adUnitId} - {error.ToString()} - {message}");
        // Optionally execute code if the Ad Unit fails to load, such as attempting to try again.
        SceneManager.LoadScene(SceneManager.GetActiveScene().name, LoadSceneMode.Single);
    }

    public void OnUnityAdsShowFailure(string adUnitId, UnityAdsShowError error, string message)
    {
        Debug.Log($"Error showing Ad Unit {adUnitId}: {error.ToString()} - {message}");
        // Optionally execite code if the Ad Unit fails to show, such as loading another ad.
        SceneManager.LoadScene(SceneManager.GetActiveScene().name, LoadSceneMode.Single);
    }

    public void OnUnityAdsShowStart(string adUnitId) {
        Debug.Log("OnUnityAdsShowStart");
    }
    public void OnUnityAdsShowClick(string adUnitId) {
        Debug.Log("OnUnityAdsShowClick");
    }
    public void OnUnityAdsShowComplete(string adUnitId, UnityAdsShowCompletionState showCompletionState) {
        Debug.Log("OnUnityAdsShowComplete");
        //gm.HideContinueScreen();
        //continueButton.GetComponentInChildren<Text>().text = "LET'S GO";
        if (adUnitId.Equals("Rewarded_Android") && showCompletionState == UnityAdsShowCompletionState.COMPLETED)
        {
            Debug.Log("Completed Rewarded Ad");
        }
        Advertisement.Load(adUnitId);
    }

    private void OnDestroy()
    {
      
    }
}

Hello everyone, I am following the latest implementation and I am having the same problem “Fake” ad like @LIU_Hanyang96 mentioned is fired in the editor but no response from listener. On device Ad is not shown at all and when I check logs through logcat I see this everytime I try to show ad:

java.lang.ClassNotFoundException: com.unity3d.ads.IUnityAdsShowListener
08-19 09:43:14.667 24240 24292 E Unity : at java.lang.Class.classForName(Native Method)
08-19 09:43:14.667 24240 24292 E Unity : at java.lang.Class.forName(Class.java:454)
08-19 09:43:14.667 24240 24292 E Unity : at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
08-19 09:43:14.667 24240 24292 E Unity : at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0)
08-19 09:43:14.667 24240 24292 E Unity : at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:95)
08-19 09:43:14.667 24240 24292 E Unity : at android.os.Handler.dispatchMessage(Handler.java:103)
08-19 09:43:14.667 24240 24292 E Unity : at android.os.Looper.loop(Looper.java:224)
08-19 09:43:14.667 24240 24292 E Unity : at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
08-19 09:43:14.667 24240 24292 E Unity : Caused by: java.lang.ClassNotFoundException: com.unity3d.ads.IUnityAdsShowListener
08-19 09:43:14.667 24240 24292 E Unity : … 8 more
08-19 09:43:14.667 24240 24292 E Unity : at UnityEngine.AndroidJNISafe.CheckException () [0x00000] in <00000000000000000000000000000000>:0
08-19 09:43:14.667 24240 24292 E Unity : at UnityEngine.AndroidJNISafe.FindClass (System.String name) [0x00000] in <00000000000000000000000000000000>:0
08-19 09:43:14.667 24240 24292 E Unity : at UnityEngine.AndroidJavaClass._AndroidJavaClass (System.String className) [0x00000] in <000

My code for Ad is here:

using UnityEngine;
using UnityEngine.Advertisements;

public class AdManager : MonoBehaviour, IUnityAdsInitializationListener, IUnityAdsLoadListener, IUnityAdsShowListener
{
    [Header("References")]
    [SerializeField] EventManager m_EventManager;
    [SerializeField] InventoryManager m_InventoryManager;

    [Header("Initialize Ads")]
    [SerializeField] string _androidGameId;
    [SerializeField] string _iOsGameId;
    [SerializeField] bool _testMode = true;
    [SerializeField] bool _enablePerPlacementMode = true;
    private string _gameId;

    [Header("Rewarded video Ad")]
    [SerializeField] string _androidAdUnitId = "Rewarded_Android";
    [SerializeField] string _iOsAdUnitId = "Rewarded_iOS";
    string _adUnitId;

    public bool videoAdReady;

    void Awake()
    {
        InitializeAds();

        // Get the Ad Unit ID for the current platform:
        _adUnitId = (Application.platform == RuntimePlatform.IPhonePlayer)
            ? _iOsAdUnitId
            : _androidAdUnitId;
    }

    public void InitializeAds()
    {
        _gameId = (Application.platform == RuntimePlatform.IPhonePlayer)
            ? _iOsGameId
            : _androidGameId;
        Advertisement.Initialize(_gameId, _testMode, _enablePerPlacementMode, this);
    }

    public void OnInitializationComplete()
    {
        LoadAd();
        Debug.Log("Unity Ads initialization complete.");
    }

    public void OnInitializationFailed(UnityAdsInitializationError error, string message)
    {
        Debug.Log($"Unity Ads Initialization Failed: {error.ToString()} - {message}");
    }

    // Load content to the Ad Unit:
    public void LoadAd()
    {
        // IMPORTANT! Only load content AFTER initialization (in this example, initialization is handled in a different script).
        Debug.Log("Loading Ad: " + _adUnitId);
        Advertisement.Load(_adUnitId, this);
    }

    // If the ad successfully loads, add a listener to the button and enable it:
    public void OnUnityAdsAdLoaded(string adUnitId)
    {
        Debug.Log("Ad Loaded: " + adUnitId);
        videoAdReady = true;
    }

  
    public void ShowAd()
    {
       
        Advertisement.Show(_adUnitId, this);
    }


    public void OnUnityAdsShowComplete(string adUnitId, UnityAdsShowCompletionState showCompletionState)
    {
        if (adUnitId.Equals(_adUnitId) && showCompletionState.Equals(UnityAdsShowCompletionState.COMPLETED))
        {
            Debug.Log("Unity Ads Rewarded Ad Completed");
            // Grant a reward.

            if(m_EventManager.doubleStarsRewardedVideo == true)
            {
                m_EventManager.doubleStarsRewardedVideo = false;
                m_EventManager.StarsDoubled();
            }

            if (m_EventManager.secondLifeRewardedVideo == true)
            {
                m_EventManager.secondLifeRewardedVideo = false;
                m_EventManager.SecondLife();
            }

            if (m_InventoryManager.AddCurrencyRewardedVideo == true)
            {
                m_InventoryManager.AddCurrencyRewardedVideo = false;
                m_InventoryManager.AddCurrencyVideoAd();
            }


            // Load another ad:
            Advertisement.Load(_adUnitId, this);
        }
    }

    // Implement Load and Show Listener error callbacks:
    public void OnUnityAdsFailedToLoad(string adUnitId, UnityAdsLoadError error, string message)
    {
        Debug.Log($"Error loading Ad Unit {adUnitId}: {error.ToString()} - {message}");
        // Use the error details to determine whether to try to load another ad.
    }

    public void OnUnityAdsShowFailure(string adUnitId, UnityAdsShowError error, string message)
    {
        Debug.Log($"Error showing Ad Unit {adUnitId}: {error.ToString()} - {message}");
        // Use the error details to determine whether to try to load another ad.
    }

    public void OnUnityAdsShowStart(string adUnitId) { }
    public void OnUnityAdsShowClick(string adUnitId) { }
}

Thank you in advance if someone could help me how to resolve this.

1 Like