Problem playing AdMob
I'm encountered this issue while playing an AdMob ad banner. The banner ad runs only in the game editing mode in the Unity editor. But when the game is compiled and running on the phone, there is no ad banner. Test mode was turned off. Does anyone know how to fix this? Maybe change Player settings or Preferences or something similar? Who had a similar problem, share your experience.
Here is code of integration Admob.
**1.**Initalize AdMob:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;
public class InitializeAdMob : MonoBehaviour
{
private string appId = "ca-app-pub-xxxxxx~xxxx";
public void Start()
{
// Initialize the Google Mobile Ads SDK.
MobileAds.Initialize(appId);
}
}
**2.**Code of show banner AdMob:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;
public class AdsManager : MonoBehaviour
{
private string appId = "ca-app-pub-xxxx~xx";
public BannerView bannerView;
public void Start()
{
MobileAds.Initialize(appId);
this.RequestBanner();
}
public void RequestBanner()
{
string AdUnitId = "ca-app-pub-xxxxxxxxxx/xxxx";
this.bannerView = new BannerView(AdUnitId, AdSize.Banner, AdPosition.Bottom);
AdRequest request = new AdRequest.Builder().Build();
this.bannerView.LoadAd(request);
}
}
Answer by Bill_G241 · Apr 26, 2021 at 09:13 AM
Have you tried to debug using Logcat on Android Studio? what message did you get? Almost the same issue in this solved post. https://answers.unity.com/questions/1832325/banner-admob-is-not-showing-on-android.html?childToView=1832350#answer-1832350