I followed the Unity Developer Integrations Guides and everything works great in the editor. When built to SDK ads do not initialize resulting in non-responsive ad buttons on Android.
- Advertisement package is up to date
- Correct game ID references for appropriate platforms.
- Attempting to initialize in the opening scene.
- Enable test mode checked.
Below is my initialization script - which returns “Unity Ads initialization complete.” in the console editor.
Any guidance would be much appreciated.
using UnityEngine;
using UnityEngine.Advertisements;
public class AdsInitializer : MonoBehaviour, IUnityAdsInitializationListener
{
[SerializeField] string _androidGameId;
[SerializeField] string _iOSGameId;
[SerializeField] bool _testMode = true;
private string _gameId;
void Awake()
{
InitializeAds();
}
public void InitializeAds()
{
_gameId = (Application.platform == RuntimePlatform.IPhonePlayer)
? _iOSGameId
: _androidGameId;
Advertisement.Initialize(_gameId, _testMode, 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}”);
}
}