【发布时间】:2017-04-05 16:11:25
【问题描述】:
我正在使用 Admob 的 InterstitialAd。我的应用程序仅在第一次被调用时在“loadAd”处崩溃,并且不可重现(它在 100-200 次或多或少的运行中发生一次)。广告单元 ID 肯定是正确的。因此,如果 loadAd 在第一次调用时没有失败,那么这次运行就不会失败。
班级成员:
InterstitialAd mInterstitialAd;
创建:
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 方法:
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;
}
}
}
catch 没有捕捉到“loadAd”的崩溃。
我怎样才能捕捉到它,或者至少让它不会让我的应用崩溃?我希望当 loadAd 失败时,不会显示任何广告。
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
我不知道最后两行是否与这次崩溃有关,但第一行是肯定的。
【问题讨论】:
-
这是原生 C 库中的错误。你在什么设备上测试?
标签: android crash admob interstitial