Answer the question
In order to leave comments, you need to log in
App crash when showing ads?
Introduced advertising into the application, everything is fine in the editor, but when building apk and draining it to the phone, when the ad loading is triggered, the application crashes. How can this be fixed?
using UnityEngine;
using GoogleMobileAds.Api;
public class BonuseHelper : MonoBehaviour {
private const string appID = "ca-app-pub-8281650214845744~2700892211";
private const string adId = "ca-app-pub-8281650214845744/9046808711";
private void Awake()
{
MobileAds.Initialize(appID);
}
// Use this for initialization
void Start()
{
}
public void ShowAD()
{
InterstitialAd ad = new InterstitialAd(adId);
AdRequest request = new AdRequest.Builder().AddTestDevice(AdRequest.TestDeviceSimulator).AddTestDevice("3ED655EC9754A480").Build();
ad.LoadAd(request);
ad.Show();
}
// Update is called once per frame
void Update()
{
}
}
Answer the question
In order to leave comments, you need to log in
https://developers.google.com/admob/unity/interstitial
Show the ad
Interstitial ads should be displayed during natural pauses in the flow of an app. Between levels of a game is a good example, or after the user completes a task. To show an interstitial, use the isLoaded() method to verify that it's done loading, then call show().
at least, do not call the display without checking)
and definitely not immediately .. let something load ..
in the documentation, the example clearly shows.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question