AdMob interstitial randomly crashes
Closed this issue · 4 comments
I'm currently running RoboVM 1.1.0 and the newest version of the AdMob binding. The banner works without any issues and the interstitial works about 75% of the time. Occasionally, my app crashes after the interstitial receives the ad (i.e. after the didReceiveAd event fires). I can post symbolicated crash reports if desired.
Here's the relevant code:
GADRequest request = GADRequest.create();
Gdx.app.debug("AdMob", "Banner is being loaded");
//I load the banner here...
banner = new GADBannerView(GADAdSize.smartBannerLandscape());
banner.setAdUnitID("my banner ad unit id here");
banner.setRootViewController(application.getUIViewController());
banner.loadRequest(request);
UIApplication.getSharedApplication().getKeyWindow().addSubview(banner);
Gdx.app.debug("Admob", "Loading interstitial...");
//I load the interstitial here...
interstitial = new GADInterstitial();
interstitial.setAdUnitID("my interstitial ad unit id here");
interstitial.setDelegate(listener);
interstitial.loadRequest(request);
And my interstitial listener:
GADInterstitialDelegateAdapter listener = new GADInterstitialDelegateAdapter(){
@Override
public void didReceiveAd (GADInterstitial ad) {
Gdx.app.debug("Admob", "Received interstitial ad");
//
//CRASH HAPPENS AFTER THIS FUNCTION RETURNS!
//
}
@Override
public void didFailToReceiveAd (GADInterstitial ad, GADRequestError error) {
Gdx.app.debug("Admob", error.description());
Gdx.app.debug("Admob", "" + error.getErrorCode());
}
};
Is anyone else experiencing this?
Hi,
I have the same issue. Once every 10 launches app crashes when ad is received. If first ad is received without crash next requests work properly.
I'm using RoboVM 1.3.0 and AdMob bindings from libGdx site (this link http://libgdx.badlogicgames.com/robovm-ios-bindings/ )
Have you managed to find solution to this issue?
Yes, I have. You ready for this?
private GADInterstitial interstitial;
@Override
public void didReceiveAd (GADInterstitial ad) {
interstitial = ad;
}
You have to make sure you reassign your local instance of GADInterstitial
with the one given to your listener function (as shown above). I did this everywhere and haven't run into any other issues since.
I'll leave this issue open because this is unexpected behavior and is very hard to debug.
Thanks for a quick response. Unfortunately it didn't resolve this issue for me.
In my case app crashed before invoking method:
public void didReceiveAd (GADInterstitial ad) {
}
But i think I found workaround:
It seems that app crashes randomly every couple of ad request and not on every device. So I tried turning off video ad type in AdMob dashboard (apps.admob.com) and I couldn't reproduce this anymore.
In the end I have 2 ads IDs: one with only text and image and second with all types enabled. I use first ID to load first ad and second ID to load every other ad.
I tested this workaround many times and it seems to work without crash.
Hope this helps someone :)
AdMob is now officially supported as a RoboPod: https://github.com/robovm/robovm-robopods
Just add the following to your Gradle:
dependencies {
... other dependencies ...
compile "org.robovm:robopods-google-mobile-ads-ios:1.5.0"
}
or maven files:
<dependency>
<groupId>org.robovm</groupId>
<artifactId>robopods-google-mobile-ads-ios</artifactId>
<version>1.5.0</version>
</dependency>
Please use the RoboPod from now and post any issues you encounter on their issues list. Thanks!