Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

470
Views
You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. Unity Google AdMob

Assets:

  1. Unity 2018.4.30f1

  2. GoogleMobileAds-v5.4.0.unitypackage plugin

  3. 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)

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!