Android - 整合Facebook观众网络后崩溃率上升。如何解决?

时间:2018-04-27 06:20:32

标签: android facebook ads facebook-audience-network

我们在一个月前整合了FAN,它开始显示崩溃率大幅上升。

我们的应用包含横幅广告,插页式广告和原生广告。

以下是有关此次崩溃的详细日志:

java.lang.NullPointerException: 
at com.facebook.ads.j.d (Unknown Source)
at com.status.activities.VideoDetailActivity$17.a (Unknown Source)
at com.facebook.ads.j$1.a (Unknown Source)
at com.facebook.ads.internal.a$3.a (Unknown Source)
at com.facebook.ads.internal.b.u$1.a (Unknown Source)
at com.facebook.ads.internal.b.t$2.a (Unknown Source)
at com.facebook.ads.internal.b.t$2.a (Unknown Source)
at com.facebook.ads.internal.i.r.b (Unknown Source)
at com.facebook.ads.internal.i.r.a (Unknown Source)
at com.facebook.ads.internal.view.v.a (Unknown Source)
at com.facebook.ads.internal.view.c.c.b.setVideoState (Unknown Source)
at com.facebook.ads.internal.view.c.c.b.onPrepared (Unknown Source)
at android.media.MediaPlayer$EventHandler.handleMessage 
(MediaPlayer.java:3021)
at android.os.Handler.dispatchMessage (Handler.java:110)
at android.os.Looper.loop (Looper.java:203)
at android.app.ActivityThread.main (ActivityThread.java:6361)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run 
(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:924)

Screenshot from play console

This shows how crashes increased after integrating facebook audience network:

EDIT1:

以下是VideoDetailActivity的非页内广告代码:

interstitialAd = new com.facebook.ads.InterstitialAd(mContext,

getResources().getString(R.string.fb_interstitial_id));
            interstitialAd.loadAd();
            try {
                interstitialAd.setAdListener(new AbstractAdListener() {
                    @Override
                    public void onAdLoaded(Ad ad) {
                        super.onAdLoaded(ad);
                        String isShow = mFirebaseRemoteConfig.getString("show_vs");
                        if (isShow.equalsIgnoreCase("true")) {
                            if (System.currentTimeMillis() - QuotesUtils.getLastSavedDateForAds(mContext) >
                                    Long.parseLong(mFirebaseRemoteConfig.getString("duration"))) {
                                if (interstitialAd.isAdLoaded())
                                    interstitialAd.show();

                                QuotesUtils.setLastSavedDateForAds(mContext, System.currentTimeMillis());
                            }
                        }
                    }
                });
            } catch (Exception e) {
                e.printStackTrace();
                Crashlytics.log("FBAd>>>" + e.getMessage());
            }

以下是来自VideoDetailActivity的横幅广告代码:

adViewFB = new com.facebook.ads.AdView(mContext,getResources().getString(R.string.fb_banner_id),AdSize.BANNER_HEIGHT_50);
            final LinearLayout adContainer = 
findViewById(R.id.banner_container);
            adContainer.addView(adViewFB);
            adViewFB.loadAd();
            adViewFB.setAdListener(new AbstractAdListener() {
                @Override
                public void onAdLoaded(Ad ad) {
                    super.onAdLoaded(ad);
                    adContainer.setVisibility(View.VISIBLE);
                }
            });

0 个答案:

没有答案