I have problem admob reference misssing
I install google admob sdk from this url https://github.com/googleads/googleads-mobile-unity/releases/tag/v5.1.0.
But the using GoogleMobileAds.Api; reference is missing.
using System;
using UnityEngine;
using GoogleMobileAds.Api; //THIS REFERENCE MISSING
public class AdmobManager : MonoBehaviour
{
private InterstitialAd interstitial;
private BannerView bannerView;
public void Start()
{
#if UNITY_ANDROID
string appId = "ca-app-pub-5911743213156480~5159541036";
#elif UNITY_IPHONE
string appId = "ca-app-pub-3940256099942544~1458002511";
#else
string appId = "unexpected_platform";
#endif
// Initialize the Google Mobile Ads SDK.
MobileAds.Initialize(appId);
RequestInterstitialAds();
RequestBanner();
}
private void RequestBanner()
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-5911743213156480/9909590242";
#elif UNITY_IPHONE
string adUnitId = "ca-app-pub-3940256099942544/2934735716";
#else
string adUnitId = "unexpected_platform";
#endif
// Create a 320x50 banner at the top of the screen.
bannerView = new BannerView(adUnitId, AdSize.SmartBanner, AdPosition.Bottom);
// Create an empty ad request.
// Load the banner with the request.
bannerView.LoadAd(CreateNewRequest());
}
public void ShowInterstitialAds()
{
if (interstitial.IsLoaded())
{
interstitial.Show();
}
}
public void ShowBannerAd()
{
if (bannerView != null)
{
bannerView.Show();
}
}
private void RequestInterstitialAds()
{
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-5911743213156480/3275382212";
#elif UNITY_IPHONE
string adUnitId = "ca-app-pub-3940256099942544/2934735716";
#else
string adUnitId = "unexpected_platform";
#endif
interstitial = new InterstitialAd(adUnitId);
interstitial.LoadAd(CreateNewRequest());
}
private AdRequest CreateNewRequest()
{
return new AdRequest.Builder().Build();
}
}
Someone can help me?
Answer by Rainbirth · May 09, 2020 at 11:41 AM
Hi, had this with latest unity admob.
remove current installation resolved & installed files, and then install the previous release.
https://github.com/googleads/googleads-mobile-unity/releases
For me the one on 18 - Mar is working.
Your answer
Follow this Question
Related Questions
How to find (and remove) references to GameObject C# 0 Answers
What are some best practices for static variables in multiplayer? 0 Answers
Why is the this object referenced to itself? 1 Answer
Inspector removing references? 1 Answer
How to select a MonoBehaviour in inspector from a cusom editor? 0 Answers