Unity Ads 4.1.0/4.2.1/4.3.0 Show invocation failed: Placement not ready. Error showing Ad Unit rewardedVideo
Unity: 2022.1.14f1
Unity Ads (Advertisement): 4.2.1 (May 19, 2022)
Unity Ads stopped working after upgrading from 4.2.1 to 4.3.0. Downgraded back to 4.2.1 (4.3.0 became unavailable in Package Manager)
Unity Ads configured by manual
https://docs.unity.com/ads/UnityDeveloperIntegrations.html
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Services.Core;
using Unity.Services.Core.Environments;
using UnityEngine.Advertisements;
public class AdsInitializer : MonoBehaviour, IUnityAdsInitializationListener
{
[SerializeField] private string _androidGameId = "39XXXXX";
[SerializeField] private string _iOSGameId = "39XXXXX ";
private string _gameId;
//
private static GameObject playerInstance;
public string environment = "c09XXXXX-XXXXX-XXXX XXXXX-XXXXXX09eb36507";
void Awake()
{
//
#if UNITY_ANDROID
//If your game is directed at mixed audiences, use this code to inform Unity Ads when users should not receive personalized ads
//for Android
MetaData metaData = new MetaData("privacy");
metaData.Set("mode", "mixed"); // This is a mixed audience game.
Advertisement.SetMetaData(metaData);
#endif
//
InitializeAds();
}
async void Start()
{
var options = new InitializationOptions()
.SetEnvironmentName(environment);
await UnityServices.InitializeAsync(options);
}
public void InitializeAds()
{
_gameId = (Application.platform == RuntimePlatform.IPhonePlayer)
? _iOSGameId
: _androidGameId;
// work mode
// Advertisement.Initialize(_gameId, false, this);//
//test mode
Advertisement.Initialize(_gameId, true, this);//
}
public void OnInitializationComplete()
{
Debug.Log("Unity Ads initialization complete."); //
}
public void OnInitializationFailed(UnityAdsInitializationError error, string message)
{
Debug.Log($"Unity Ads Initialization Failed: {error.ToString()} - {message}");
}
}
RewardedAds.cs
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Advertisements;
using UnityEngine.SceneManagement;
public class RewardedAds : MonoBehaviour, IUnityAdsLoadListener, IUnityAdsShowListener
{
string _adUnitId = null;
//
void Awake()
{
#if UNITY_IOS
_adUnitId = "rewardedVideo";
#endif
#if UNITY_ANDROID
_adUnitId = "rewardedVideo";
#endif
}
// 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);
if (adUnitId.Equals(_adUnitId))
{
}
}
// Implement a method to execute when the user clicks the button.
public void ShowAd()
{
// Then show the ad:
Advertisement.Show(_adUnitId, this);
}
// Implement the Show Listener's OnUnityAdsShowComplete callback method to determine if the user gets a reward:
public void OnUnityAdsShowComplete(string adUnitId, UnityAdsShowCompletionState showCompletionState)
{
// Debug.Log("do it");
Debug.Log(adUnitId);
if (adUnitId.Equals(_adUnitId) && showCompletionState.Equals(UnityAdsShowCompletionState.COMPLETED))
{
Debug.Log("Unity Ads Rewarded Ad Completed");
// Grant a reward.
int iigold = PlayerPrefs.GetInt("iigold");
igold = iigold + 1;
PlayerPrefs.SetInt("iigold", iigold);
}
}
// 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) { }
void OnDestroy()
{
}
}
In Unity Editor Unity Ads work fine
But on real device Unity Ads donât work, throws errors in the log:
Show invocation failed: Placement not ready
Error showing Ad Unit rewardedVideo:
Full Log
08-25 12:21:08.385 20868 20922 I Unity : Unity.Services.Analytics.Internal.Buffer:FlushToDisk()
08-25 12:21:08.385 20868 20922 I Unity : Unity.Services.Analytics.Internal.<>c__DisplayClass13_0:<FlushBufferToService>b__1(Int64)
08-25 12:21:08.385 20868 20922 I Unity : UnityEngine.AsyncOperation:InvokeCompletionEvent()
08-25 12:21:08.385 20868 20922 I Unity :
08-25 12:21:09.446 20868 21226 W UnityAds: com.unity3d.services.core.api.Sdk.logWarning() (line:79) :: {"message":"model: DeviceInfo key: openAdvertisingTrackingId with value: null: null is not in: string,undefined","name":"CheckValueError"}
08-25 12:21:09.841 20868 21226 I UnityAds: com.unity3d.services.core.api.Sdk.logInfo() (line:85) :: Requesting configuration from https://publisher-config.unityads.unity3d.com/games/3968719/configuration?deviceMake=Sony&screenDensity=560&screenSize=268435810&idfi=6fb6ed07774138f488750e4fcca7585a&advertisingTrackingId=00000000-0000-0000-0000-000000000000&limitAdTracking=false&installationId=6fb6ed07774138f488750e4fcca7585a&connectionType=cellular&screenHeight=1440&screenWidth=2712&bundleId=ssfm.proj.ew&encrypted=true&rooted=false&platform=android&sdkVersion=4210&osVersion=10&deviceModel=H9493&language=ru_RU&test=true&analyticsUserId=6fb6ed07774138f488750e4fcca7585a&analyticsSessionId=2121235812310092326&first=true&framework=%5Bobject%20Object%5D&adapter=%5Bobject%20Object%5D&userLevelFlagDetected=false&dpm=mixed
08-25 12:21:10.870 20868 21226 I UnityAds: com.unity3d.services.core.api.Sdk.logInfo() (line:85) :: Received configuration for token eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhcHAiOjIwMiwiYXBwTGV2ZWxDb3BwYSI6dHJ1ZSwiYXR0IjowLCJhdWMiOjI1MCwiYXVpIjoyMjgsImF6cCI6ImQyM2FkYjJjLTAwNGItNGE0NC1hMjUzLWZhYTVmNmVkMTRjOSIsImNhbGN1bGF0ZWRDb3BwYSI6dHJ1ZSwiY29uc2VudCI6ZmFsc2UsImNvbnRleHR1YWxPbmx5IjpmYWxzZSwiY3BpIjoxNzcsImNyZWF0ZWQiOjE2NjEzOTQwNzEwMDAsImRsdCI6MCwiZHQiOjAsImV0dCI6WzIxNDc0ODM4ODUsNTM0NSw1MzQ5LDU0MzEsNzM0Niw1OTYzLDcxMDUsNTc1Niw3MzEwLDczNDddLCJleHAiOjE2NjI2MDM2NzEsImlhcCI6MTU5LCJpYXQiOjE2NjEzOTQwNzEsImlnIjoiVlpuWmhMSHpVRDVzWnlJR2J6SHNIVGxYcXZtbHRyTDRiVm5JNFV1bm1XSEV1Q0pqMEdLamM1SXkwbGQ2bWVpVGJEUVNhUT09IiwiaW5zdGFsbGF0aW9uSWQiOiI2ZmI2ZWQwNzc3NDEzOGY0ODg3NTBlNGZjY2E3NTg1YSIsImlzcyI6ImFkcy1zZGstY29uZmlndXJhdGlvbi51bml0eWFkcy51bml0eTNkLmNvbSIsImxlZ2FsVGVycml0b3J5IjowLCJsdHYiOjI4LCJtaXhlZCI6ZmFsc2UsInBybyI6MTczLCJwcm94aWVkIjpmYWxzZSwic3ViIjoicUlhdit5bEN5M0lkd2tMSzhLRXVyeVlrK1oxRkZlZFE1YTVFQkhFeVJySnozeE0yakZoVXlSUXJwWkszazdFeTdJLzQ2UT09IiwidGd0IjoyMzMsInhwciI6MjA1fQ.8NO_BLIeW_2AukMZF1SDkk8PveGJduQZTphr_kd7qSg (A/B group 5)
08-25 12:21:10.929 20868 20922 I Unity : Unity Ads initialization complete.
08-25 12:21:10.929 20868 20922 I Unity : UnityEngine.Advertisements.Utilities.CoroutineExecutor:Update()
08-25 12:21:10.929 20868 20922 I Unity :
08-25 12:21:12.441 20868 21226 I UnityAds: com.unity3d.services.core.api.Sdk.logInfo() (line:85) :: Webview started using the latest version
08-25 12:21:22.457 20868 21226 E UnityAds: com.unity3d.services.core.api.Sdk.logError() (line:73) :: Show invocation failed: Placement not ready
08-25 12:21:22.489 20868 20922 I Unity : Error showing Ad Unit rewardedVideo: NOT_READY - Placement not ready08-25 12:21:22.489 20868 20922 I Unity : RewardedAds:OnUnityAdsShowFailure(String, UnityAdsShowError, String)08-25 12:21:22.489 20868 20922 I Unity : UnityEngine.Advertisements.Utilities.CoroutineExecutor:Update()
08-25 12:21:22.489 20868 20922 I Unity :
08-25 12:21:58.341 20868 20922 I Unity : Flushed up to token index 89, cache file is 2512B
08-25 12:21:58.341 20868 20922 I Unity : Unity.Services.Analytics.Internal.Buffer:FlushToDisk()
08-25 12:21:58.341 20868 20922 I Unity : Unity.Services.Analytics.Internal.<>c__DisplayClass13_0:<FlushBufferToService>b__1(Int64)
08-25 12:21:58.341 20868 20922 I Unity : UnityEngine.AsyncOperation:InvokeCompletionEvent()
08-25 12:21:58.341 20868 20922 I Unity :0