'IUnityAdsListener' could not be found

Full error: error CS0246: The type or namespace name ‘IUnityAdsListener’ could not be found (are you missing a using directive or an assembly reference?)

Unity 2019.4.17f1


Ads has been turned on


Package Manager shows Advertisement 3.5.2 installed

My C# script:

using System.Collections;
using System.Collections.Generic;
using UnityEngine.Advertisements;
using UnityEngine;

public class AdsManager : MonoBehaviour, IUnityAdsListener
{

string  googlePlayID        = "4055395";
string  applePlayID         = "4055394";
string  myVideoId           = "video";
string  myRewardVideoId     = "rewardedVideo";
string  myInterstatialId    = "Interstatial";
string  myBannerId          = "Banner";
bool    isTestGameMode  = false;

// Start is called before the first frame update
void Start()
{
    Advertisement.AddListener (this);
    Advertisement.Initialize(googlePlayID, isTestGameMode);
    
}

public void DisplayInterstitialAds() {

    if (Advertisement.IsReady(myInterstatialId)) {
        Advertisement.Show(myInterstatialId);
        }
}

public void DisplayVideoAds() {

    Advertisement.Show(myRewardVideoId);

}

// Implement IUnityAdsListener interface methods:
public void OnUnityAdsDidFinish (string surfacingId, ShowResult showResult) {
    // Define conditional logic for each ad completion status:
    if (showResult == ShowResult.Finished) {
        // Reward the user for watching the ad to completion.
        Debug.LogWarning ("You get a reward.");
    } else if (showResult == ShowResult.Skipped) {
        // Do not reward the user for skipping the ad.
        Debug.LogWarning ("You don't get a reward.");
    } else if (showResult == ShowResult.Failed) {
        Debug.LogWarning ("The ad did not finish due to an error.");
    }
}

public void OnUnityAdsReady (string surfacingId) {
    // If the ready Ad Unit or legacy Placement is rewarded, show the ad:
    if (surfacingId == myRewardVideoId) {
        // Optional actions to take when theAd Unit or legacy Placement becomes ready (for example, enable the rewarded ads button)
    }
}

public void OnUnityAdsDidError (string message) {
    // Log the error.
}

public void OnUnityAdsDidStart (string surfacingId) {
    // Optional actions to take when the end-users triggers an ad.
} 

// When the object that subscribes to ad events is destroyed, remove the listener:
public void OnDestroy() {
    Advertisement.RemoveListener(this);
}

}

I had this happen to me so I thought I would add to the thread in case anyone else comes across it. The adverts package was installed for me so I uninstalled, then re-installed and the errors went away.

Hope that’s useful for someone.

@PolymathicIndustries, I updated Advertisement to 3.7.5 (the latest and greatest), closing and re-opening the Unity editor two of times. No joy. I get the same error:

Assets/scripts/WWIFC.cs(28,37): error CS0246: The type or namespace name ‘IUnityAdsListener’ could not be found (are you missing a using directive or an assembly reference?)

I am at the same Unity version: 2019.4.17f1

It seems like they’ve made some “braking changes” that everybody love so much))). Support gave me a link on new version of implementing (you should use all three new interfaces, as for me that worked) i’ve copied the code and made some minor changes (like removed button). Had some practice in reading docs))
https://docs.unity.com/ads/ImplementingRewardedAdsUnity.html

Not sure if you still need a solution, but for future viewers, this is an update issue. To resolve this head over to the package manager, select Advertisements as shown in finneous’ screenshots above, except this time you need to update it. Click on Advertisements and select/click on the latest/higher number. Once up date your package to the latest version the errors in your IDE will go away, having been resolved.

Hope this helps @finneous

I think the interfaces have changed for unity ads, there are now 3 listener interfaces instead of 1 and the formats have changed significantly. But the worst part is that it is not mentioned in the change-logs or documentation but only in the examples.

SOLVED:
Got to package manager, In project, Advertisement, change currently installed to recommended.

SOLVED

I also came across this same error… This happened when I duplicated the original project for random changes which I don’t want to make in original project, however original project is working good and whereas duplicate project having these errors.

Originally I created the copy of real project to have separate work space for every different app store, because every other store requires unique SDK for monetization, so implementing them means major changes in project and I don’t want to take any other risks.

Fixed it by changing plate form to android (lol) and then updating Advertisement to latest version.
I believe @finneous is having similar scenario.

I had this issue, tried many solutions, all doesnt work.

Solved by switching to other platform then back to original platform. Just try this when you have no other choice.

Hi there i have the same problem, i came back to unity after a year and get that error, i read some documentation but i can’t figure out how to fix it. i have Ads Meditation Installed version 1.0.0 and Advertisement package version 4.3.0
Thanks in advice! @finneous

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Advertisements;


public class AdsManager : MonoBehaviour, IUnityAdsListener
{
#if UNITY_IOS
    private string gameId = "4195551";
#elif UNITY_ANDROID
    private string gameId = "4195550";
#endif
    bool testMode = false;

    public GameObject X3Button;
    public OfflineProgress scriptOffline;
    public GameManager scriptManager;
    public AnimationController animationController;

    string mySurfacingIdX3 = "RewardX3";
    string mySurfacingIdEvento1 = "RewardedEvento1";
    string mySurfacingIdGemme = "RewardGemme";
    string mySurfacingIdRewardX2per20min = "RewardX2per20min";

    void Start()
    {
        Advertisement.AddListener(this);
        // Initialize the Ads service:
        Advertisement.Initialize(gameId, testMode);
    }

    public void ShowInterstitialAd()
    {
        // Check if UnityAds ready before calling Show method:
        if (Advertisement.IsReady())
        {
            Advertisement.Show(mySurfacingIdX3);
            // Replace mySurfacingId with the ID of the placements you wish to display as shown in your Unity Dashboard.
        }
        else
        {
            Debug.Log("Interstitial ad not ready at the moment! Please try again later!");
        }
    }

    public void ShowRewardedVideo(int adsType)
    {
        // Check if UnityAds ready before calling Show method:
        if (Advertisement.IsReady(mySurfacingIdX3) && adsType == 1)     //x3 on your btc
        {
            Advertisement.Show(mySurfacingIdX3);
            Debug.Log("Showing reward x3");
        }
        else if (Advertisement.IsReady(mySurfacingIdEvento1) && adsType == 2)    //evento1 reward
        {
            Advertisement.Show(mySurfacingIdEvento1);
            Debug.Log("Showing reward evento1");
        }
        else if (Advertisement.IsReady(mySurfacingIdGemme) && adsType == 3)    //30 free gems
        {
            Advertisement.Show(mySurfacingIdGemme);
            Debug.Log("Showing reward free gems");
        }
        else if (Advertisement.IsReady(mySurfacingIdRewardX2per20min) && adsType == 4) //x2 for 20 min Reward
        {
            Advertisement.Show(mySurfacingIdRewardX2per20min);
            Debug.Log("Showing reward x2 per 20 min");
        }

        else
        {
            Debug.Log("Rewarded video is not ready at the moment! Please try again later!");
        }
    }

    // Implement IUnityAdsListener interface methods:
    public void OnUnityAdsDidFinish(string surfacingId, ShowResult showResult)
    {
        // Define conditional logic for each ad completion status:
        if (showResult == ShowResult.Finished && surfacingId == mySurfacingIdX3)        //reward x3 on your btc
        {
            GameManager.BTC += OfflineProgress.daAggiungere;
            scriptOffline.X3Applicato.SetActive(true);
            Debug.Log("X3 On Your BTC!");
        }
        else if (showResult == ShowResult.Finished && surfacingId == mySurfacingIdEvento1)      //reward evento 1
        {
            GameManager.BTC += EventManager.RandomNumber;
            animationController.OpenScreenEvento1();
            Debug.Log("Reward Evento 1");
        }
        else if (showResult == ShowResult.Finished && surfacingId == mySurfacingIdGemme)      //30 free gems
        {
            GemsManager.Gems += 20;
            Debug.Log("+20 free gems");
        }
        else if (showResult == ShowResult.Finished && surfacingId == mySurfacingIdRewardX2per20min)      //30 free gems
        {
            scriptManager.addSeconds();
            Debug.Log("x2 per 20 min");
        }
        else if (showResult == ShowResult.Skipped)
        {
            // Do not reward the user for skipping the ad.
        }
        else if (showResult == ShowResult.Failed)
        {
            Debug.LogWarning("The ad did not finish due to an error.");
        }
    }

    public void OnUnityAdsReady(string surfacingId)
    {
        // If the ready Ad Unit or legacy Placement is rewarded, show the ad:
        if (surfacingId == mySurfacingIdX3)
        {
            // Optional actions to take when theAd Unit or legacy Placement becomes ready (for example, enable the rewarded ads button)
        }
    }

    public void OnUnityAdsDidError(string message)
    {
        // Log the error.
    }

    public void OnUnityAdsDidStart(string surfacingId)
    {
        // Optional actions to take when the end-users triggers an ad.
    }

    // When the object that subscribes to ad events is destroyed, remove the listener:
    public void OnDestroy()
    {
        Advertisement.RemoveListener(this);
    }
    private void Update()
    {
        if (Advertisement.IsReady(mySurfacingIdX3))
        {
            X3Button.SetActive(true);
        }
        else
        {
            X3Button.SetActive(false);
        }
    }
}

best way to resolve this problem to remove the pluginGley and to improt the new version of the gley