Error, platform-specific implementation not set while implementing AdColony ads in Unity

182 Views Asked by At

Hi I am trying to implement adColony ads in Unity but getting the following error:

Error, platform-specific implementation not set
UnityEngine.Debug:LogError (object)
AdColony.Ads:get_SharedInstance () (at Assets/AdColony/Scripts/AdColony.cs:299)
AdColony.Ads:Configure (string,AdColony.AppOptions,string[]) (at Assets/AdColony/Scripts/AdColony.cs:30)
AdColonyAds:ConfigureAdColony () (at Assets/AdColonyAds.cs:68)
AdColonyAds:Start () (at Assets/AdColonyAds.cs:39)

I tried to look for the answers and found something here and here , but it didn't help in any way. Anyways here is my code , you can have a look into it

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

public class AdColonyAds : MonoBehaviour
{
    public static AdColonyAds instance;
    public string AdColonyAdsAppId = "app83656343d944b2991";
    public string[] zoneIds = new string[] { "vz23f8dee2bb84b7c90", "vz2b5557ec5924be6a1" };
    //banner,interstitial in  the inspector
    // Start is called before the first frame update
    AdColony.AdColonyAdView adView;
    string appID = "";
    string iosAppID = "";
    string windowsAppID = "";

    AdColony.InterstitialAd _interstitialAd = null;

    private void Awake() {
         if (instance != null && instance != this)
        {
            Destroy(gameObject);
            return;
        }
        instance = this;
        DontDestroyOnLoad(this);

        #if UNITY_IPHONE
            appID = iosAppID;
        #elif UNITY_ANDROID
            appID = AdColonyAdsAppId;
        #elif UNITY_WSA_10_0 || UNITY_WINRT_8_1 || UNITY_METRO
            appID = windowsAppID;
        #endif
    }
    void Start()
    {
        ConfigureAdColony();
        RequestBannerAd();
        ShowBannerAd();
        RequestInterstialAd();
    }
    private void OnEnable()
    {

    }

    private void OnDisable()
    {
        AdColony.Ads.OnAdViewLoaded -= (AdColony.AdColonyAdView ad) =>
        {
            adView = ad;
        };

        AdColony.Ads.OnAdViewFailedToLoad -= (AdColony.AdColonyAdView ad) =>
        {
            Debug.Log("Banner ad failed to load");
        };
    }




    private void ConfigureAdColony()
    {
        AdColony.AppOptions options = new AdColony.AppOptions ();
        AdColony.Ads.Configure(appID, options, zoneIds);

        AdColony.Ads.OnAdViewLoaded += (AdColony.AdColonyAdView ad) =>
        {
            adView = ad;
        };

        AdColony.Ads.OnAdViewFailedToLoad += (AdColony.AdColonyAdView ad) =>
        {
            Debug.Log("Banner ad failed to load");
        };


        AdColony.Ads.OnRequestInterstitial += (AdColony.InterstitialAd ad) =>
        {
            _interstitialAd = ad;
        };

        AdColony.Ads.OnExpiring += (AdColony.InterstitialAd ad) =>
        {
            AdColony.Ads.RequestInterstitialAd(zoneIds[1], null);
        };
    }

    public void RequestBannerAd()
    {
        AdColony.AdOptions adOptions = new AdColony.AdOptions();
        adOptions.ShowPrePopup = false;
        adOptions.ShowPostPopup = false;
        AdColony.Ads.RequestAdView(zoneIds[0], AdColony.AdSize.Banner, AdColony.AdPosition.Top, adOptions);
    }

    public void ShowBannerAd()
    {
        if (adView != null) 
        adView.ShowAdView();
    }

    public void HideBannerAd()
    {
        if (adView != null) 
        adView.ShowAdView();
    }
    public void CleanBannerAd()
    {
        if (adView != null) 
        adView.DestroyAdView();
    }
    
    public void RequestInterstialAd()
    {
        AdColony.AdOptions adOptions = new AdColony.AdOptions();
        adOptions.ShowPrePopup = false;
        adOptions.ShowPostPopup = false;
        AdColony.Ads.RequestInterstitialAd(zoneIds[1], adOptions);
    }

    public void ShowInterstital()
    {
        if (_interstitialAd != null) 
            AdColony.Ads.ShowAd(_interstitialAd);
    }

    public void DestroyInterstital()
    {
         if (_interstitialAd != null) 
        _interstitialAd.DestroyAd();
    }

    private void OnDestroy() {
        CleanBannerAd();
        DestroyInterstital();
    }

    // Update is called once per frame
    void Update()
    {

    }
}

Scrrenshot of the error

I tried to include the remove the line AppOptions above AdColony.Ads.Configure(appID, options, zoneIds);

and make it

 AdColony.Ads.Configure(appID, null, zoneIds); 

But it still doesn't work as such.

0

There are 0 best solutions below