Assets:
Unity 2018.4.30f1
GoogleMobileAds-v5.4.0.unitypackage plugin
Enable In GoogleMobileAdsSettings - GoogleAdMob and I Added the App Id to Android and IOS
adbanner.cs script
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using GoogleMobileAds.Api;
public class AdBanner : MonoBehaviour
{
private BannerView bannerView;
private string idApp, idBanner;
public void Start()
{
idApp = "ca-app-pub-2584265330622657~8465399911";
idBanner = "ca-app-pub-2584265330622657/1877307815";
MobileAds.Initialize(idApp);
RequestBannerAd();
}
public void RequestBannerAd()
{
bannerView = new BannerView(idBanner, AdSize.Banner, AdPosition.Bottom);
AdRequest request = AdRequestBuild();
bannerView.LoadAd(request);
}
AdRequest AdRequestBuild()
{
return new AdRequest.Builder().Build();
}
}
I have this error that does not allow me to build the application further for xcode
The all errors :
You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. MonoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all UnityEngine.MonoBehaviour:.ctor() ButtonBehaviour:.ctor() GoogleMobileAds.Unity.BannerClient:CreateButtonBehavior() (at Assets/GoogleMobileAds/Platforms/Unity/BannerClient.cs:64) GoogleMobileAds.Unity.BannerClient:ShowBannerView() (at Assets/GoogleMobileAds/Platforms/Unity/BannerClient.cs:143) GoogleMobileAds.Unity.BannerClient:LoadAd(AdRequest) (at Assets/GoogleMobileAds/Platforms/Unity/BannerClient.cs:123) GoogleMobileAds.Api.BannerView:LoadAd(AdRequest) (at Assets/GoogleMobileAds/Api/BannerView.cs:61) AdBanner:RequestBannerAd() (at Assets/Scripts/AdBanner.cs:25) AdBanner:Start() (at Assets/Scripts/AdBanner.cs:18)