- Home /
NullReferenceException at at GoogleMobileAds.Api.MobileAds.Initialize (System.Action`1[T] initCompleteAction) [0x00000] in <00000000000000000000000000000000>:0
Hello. There is a problem with google AdMob. Test ads are shown in the editor (There are no errors in the editor), but real ads are not showing on my phone. Then I decided to use USB debugging and found out that the following error occurs:
"NullReferenceException: Object reference not set to an instance of an object. at GoogleMobileAds.Api.MobileAds.Initialize (System.Action`1[T] initCompleteAction) [0x00000] in :0 at Show_ads.Start () [0x00000] in :0"
Here's my script:
using GoogleMobileAds.Api; using System.Collections; using System; using UnityEngine.Scripting; [assembly: Preserve]
public class Show_ads : MonoBehaviour { //ADS---------------------------- private RewardedAd rewardedAd; private const string RewardedID = "id"; //ADS----------------------------
void Start()
{
MobileAds.Initialize(initStatus => { });
LoadRewardedAD();
}
private void LoadRewardedAD()
{
//load-ad
rewardedAd = new RewardedAd(RewardedID);
AdRequest adRequest = new AdRequest.Builder().Build();
rewardedAd.LoadAd(adRequest);
rewardedAd.OnUserEarnedReward += HandleUserEarnedReward;
}
//Called from another script
public void ShowRewardedAD()
{
if (rewardedAd.IsLoaded())
{
rewardedAd.Show();
}
}
public void HandleUserEarnedReward(object sender, Reward args)
{
if (Reward_type == 0)
{
//gem
}
else if (Reward_type == 1)
{
//coin
}
else if (Reward_type == 2)
{
//Respawn
}
}
private IEnumerator WaitAD()
{
yield return new WaitForSeconds(3);
LoadRewardedAD();
}
}
Who can help?
Answer by Tuanlak91 · Sep 06, 2021 at 09:15 AM
Hello Hacker237 did you fix this error? I also got the same error.
@Tuanlak91 hi, did you perhaps manage to solve this ? I am having the same problem :/
Answer by erikp93 · Jan 03 at 12:37 AM
hi Hacker237, did you manage to solve this issue ? if so, how did you do it ?
Answer by Hacker237 · Jan 07 at 10:03 AM
No I have not solve this error yet. I just dont use Admob anymore. I asked a lot about this problem but nobody can help me.
Your answer
Follow this Question
Related Questions
Working .pod with admob and googleplayservice for ios 0 Answers
AdMob iOS and Android 1 Answer
'GADAdmobExtras.h' file not found 0 Answers
iOS FPS Kit 0 Answers
Instantiating class creating copies with same instance ID of 0 0 Answers