Unity Android build errors

When i try to build my project for android i got this errors.

Assets\Plugins\GameAnalytics\Plugins\Scripts\ILRD\AdMob\GAAdMobIntegration.cs(23,12): error CS1061: 'BannerView' does not contain a definition for 'OnPaidEvent' and no accessible extension method 'OnPaidEvent' accepting a first argument of type 'BannerView' could be found (are you missing a using directive or an assembly reference?)

Assets\Plugins\GameAnalytics\Plugins\Scripts\ILRD\AdMob\GAAdMobIntegration.cs(38,12): error CS1061: 'InterstitialAd' does not contain a definition for 'OnPaidEvent' and no accessible extension method 'OnPaidEvent' accepting a first argument of type 'InterstitialAd' could be found (are you missing a using directive or an assembly reference?)

Assets\Plugins\GameAnalytics\Plugins\Scripts\ILRD\AdMob\GAAdMobIntegration.cs(53,12): error CS1061: 'RewardedAd' does not contain a definition for 'OnPaidEvent' and no accessible extension method 'OnPaidEvent' accepting a first argument of type 'RewardedAd' could be found (are you missing a using directive or an assembly reference?)

Assets\Plugins\GameAnalytics\Plugins\Scripts\ILRD\AdMob\GAAdMobIntegration.cs(68,12): error CS1061: 'RewardedInterstitialAd' does not contain a definition for 'OnPaidEvent' and no accessible extension method 'OnPaidEvent' accepting a first argument of type 'RewardedInterstitialAd' could be found (are you missing a using directive or an assembly reference?)

Also my admanager script look like;

using System;
using UnityEngine;
using GoogleMobileAds.Api;

public class FAMADManager : MonoBehaviour
{
   
    private bool _adShowing = false;
    private RewardedAd continueAd;
    private RewardedAd levelCompleteAd;
    private RewardedAd comeBackAd;
    private string continueAdCode = "ca-app-pub-3940256099942544/5224354917";
    private string levelCompleteAdCode = "ca-app-pub-3940256099942544/5224354917";
    private string comeBackAdCode = "ca-app-pub-3940256099942544/5224354917";

    void Start()
    {
        MobileAds.Initialize((InitializationStatus initStatus) =>{});
        RequestContinueAd();
        RequestLevelCompleteAd();
        RequestComeBackAd();
    }

    private void RequestContinueAd(){
      var adRequest = new AdRequest.Builder()
              .Build();

      RewardedAd.Load(continueAdCode, adRequest,
          (RewardedAd ad, LoadAdError error) =>
          {
              if (error != null || ad == null)
              {
                  return;
              }
              continueAd = ad;
          });
    }

    private void RequestLevelCompleteAd(){
      var adRequest = new AdRequest.Builder()
              .Build();

      RewardedAd.Load(levelCompleteAdCode, adRequest,
          (RewardedAd ad, LoadAdError error) =>
          {
              // if error is not null, the load request failed.
              if (error != null || ad == null)
              {
                  return;
              }
              levelCompleteAd = ad;
          });
    }

    private void RequestComeBackAd(){
      var adRequest = new AdRequest.Builder()
              .Build();

      RewardedAd.Load(comeBackAdCode, adRequest,
          (RewardedAd ad, LoadAdError error) =>
          {
              // if error is not null, the load request failed.
              if (error != null || ad == null)
              {
                  return;
              }
              comeBackAd = ad;
          });
    }

    public void ShowContinueAd(){
        Time.timeScale = 0;
        _adShowing = true;
        if (_adShowing && continueAd != null && continueAd.CanShowAd())
        {
            continueAd.Show((Reward reward) =>
            {
                Time.timeScale = 1f;
                _adShowing = false;
            });
        }
        continueAd.OnAdFullScreenContentClosed += () =>
        {
            RequestContinueAd();
        };
    }

    public void ShowLevelCompleteAd(){
        _adShowing = true;
        if (_adShowing && levelCompleteAd != null && levelCompleteAd.CanShowAd())
        {
            levelCompleteAd.Show((Reward reward) =>{
                _adShowing = false;
            });
        }
        levelCompleteAd.OnAdFullScreenContentClosed += () =>
        {
            RequestLevelCompleteAd();
        };
    }

    public void ShowComeBackAd(){
        _adShowing = true;
        if (_adShowing && comeBackAd != null && comeBackAd.CanShowAd())
        {
            comeBackAd.Show((Reward reward) =>{
                _adShowing = false;
            });
        }
        comeBackAd.OnAdFullScreenContentClosed += () =>
        {
            RequestComeBackAd();
        };
    }

}

Solved.

Please share how you solved it.

Yes please share solution. I’ve been trying to find a solution for this. I have both Admob and Google Analytics installed as packages but there is a conflict between them. Thanks in advance.

A workaround is modifying GAAdMobIntegration.cs

change this:
ad.OnPaidEvent += (sender, args) =>
to this:
ad.OnAdPaid += (sender) =>

and comment every line that includes args

OR just copy the file i attached

9050455–1250560–GAAdMobIntegration.cs (3.34 KB)

2 Likes

You just safe my day