I'm using InterstitialAd by Admob. My app crashes at "loadAd" only in the first time it's called, and it's not reproducible (it happens once in 100-200 runs less or more). the ad unit id is correct for sure. So if loadAd doesn't fail in the first time it's called, it won't fail at all at this run.
class member:
InterstitialAd mInterstitialAd;
onCreate:
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId(getResources().getString(R.string.interstitial_ad_unit_id));
mInterstitialAd.setAdListener(new AdListener() {
@Override
public void onAdClosed() {
requestNewInterstitial();
finish();
}
});
requestNewInterstitial();
requestNewInterstitial method:
private void requestNewInterstitial() {
if (mInterstitialAd != null) {
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(getResources().getString(R.string.test_device))
.build();
if (adRequest == null) {
return;
}
// HERE'S THE CRASH
try {
mInterstitialAd.loadAd(adRequest);
}catch(Exception e) {
return;
}
}
}
The catch doesn't catch the crash of "loadAd".
How can I catch it or at least cause it not to crash my app? I wish that when loadAd fails, no ad will be displayed.
LOGCAT:
A/libc: Fatal signal 5 (SIGTRAP), code 1 in tid 27794 (AdWorker(Defaul)
W/VideoCapabilities: Unrecognized profile 2130706433 for video/avc
I/VideoCapabilities: Unsupported profile 4 for video/mp4v-es
I don't know if the last 2 lines are about this crash but the first one is for sure.