Buildbox在游戏分层时崩溃

时间:2018-12-04 11:45:29

标签: android admob buildbox

启动时崩溃,并且错误与广告相关,这里是logcat

java.lang.IllegalStateException: The ad size and ad unit ID must be set before loadAd is called.
    at com.google.android.gms.internal.zzmw.zza(Unknown Source:211)
    at com.google.android.gms.ads.BaseAdView.loadAd(Unknown Source:6)
    at com.google.android.gms.ads.AdView.loadAd(Unknown Source:0)
    at com.secrethq.ads.PTAdAdMobBridge$1.run(PTAdAdMobBridge.java:72)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6680)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:495)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

这是PTAdAdMobBridge上方法的代码:

public static void initBanner(){
    Log.v(TAG, "PTAdAdMobBridge  -- initBanner");
    PTAdAdMobBridge.s_activity.get().runOnUiThread( new Runnable() {
        public void run() {

            if(PTAdAdMobBridge.adView != null){
                return;
            }

            FrameLayout frameLayout = (FrameLayout)PTAdAdMobBridge.activity.findViewById(android.R.id.content);
            RelativeLayout layout = new RelativeLayout( PTAdAdMobBridge.activity );
            frameLayout.addView( layout );

            RelativeLayout.LayoutParams adViewParams = new RelativeLayout.LayoutParams(
                    AdView.LayoutParams.WRAP_CONTENT,
                    AdView.LayoutParams.WRAP_CONTENT);
            adViewParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
            adViewParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);

            PTAdAdMobBridge.adView = new AdView( PTAdAdMobBridge.activity );
            PTAdAdMobBridge.adView.setAdSize(AdSize.SMART_BANNER);
            PTAdAdMobBridge.adView.setAdUnitId( PTAdAdMobBridge.bannerId() );

            layout.addView(PTAdAdMobBridge.adView, adViewParams);
            PTAdAdMobBridge.adView.setVisibility( View.INVISIBLE );

            AdRequest adRequest = getAdRequest();
            PTAdAdMobBridge.adView.loadAd( adRequest );
        }
    });

}

ad sizead unit ID已经设置好了,我不为什么要问他们。 感谢大家的帮助

0 个答案:

没有答案