接收插页式广告adob的间歇性失败 - TransactionTooLargeException

时间:2014-11-30 19:10:14

标签: java android cocos2d-x

我使用的是Google Play Services修订版21。

我的游戏中有以下活动。横幅广告的效果非常好,插页式广告有时只会出现。 showInterstitial方法通过JNI从我用C ++编写的游戏代码中调用,但我不认为这与该问题有任何关联。

public class AppActivity extends Cocos2dxActivity {
        private AdView adView;
        private static final String AD_UNIT_ID_BANNER = "my banner id";
        private static final String AD_UNIT_ID_INTERSTITIAL = "my interstitial id"; 
        private static AppActivity _appActivity;
        private static InterstitialAd interstitial;

        @Override
        protected void onCreate(Bundle savedInstanceState){
            super.onCreate(savedInstanceState);

            setupBannerAd();
            setupInterstitial();

            _appActivity = this;
        }

        private void setupBannerAd() {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

            int width = getDisplaySize(getWindowManager().getDefaultDisplay()).x;

            LinearLayout.LayoutParams adParams = new LinearLayout.LayoutParams(
                    width, LinearLayout.LayoutParams.WRAP_CONTENT);

            adView = new AdView(this);
            adView.setAdSize(AdSize.SMART_BANNER);
            adView.setAdUnitId(AD_UNIT_ID_BANNER);

            AdRequest adRequest = new AdRequest.Builder()
                .addTestDevice("74CF565D181FBE42D5B6C217467E561F")
                .build();

            adView.loadAd(adRequest);
            adView.setBackgroundColor(Color.BLACK);
            adView.setBackgroundColor(0);
            addContentView(adView,adParams);
        }

        private void setupInterstitial() {
            interstitial = new InterstitialAd(this);
            interstitial.setAdUnitId(AD_UNIT_ID_INTERSTITIAL);
            AdRequest adRequest = new AdRequest.Builder()
                .addTestDevice("74CF565D181FBE42D5B6C217467E561F")
                .build();
            interstitial.loadAd(adRequest);
        }

        public static void showInterstitial() {
            _appActivity.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    if (interstitial.isLoaded()) {
                        interstitial.show();
                    }

                    AdRequest adRequest = new AdRequest.Builder()
                        .addTestDevice("74CF565D181FBE42D5B6C217467E561F")
                        .build();
                    //TODO: sometimes this loadAd call fails. why?
                    //set onFailedToReceiveAd listener and do another loadAd?
                    interstitial.loadAd(adRequest);
                }
            });
        }
        //other methods here
    }

在请求其他插页式广告时,我偶尔会收到以下错误:

!!! FAILED BINDER TRANSACTION !!!

Could not fetch ad response from ad request service.

android.os.TransactionTooLargeException
at android.os.BinderProxy.transact(Native Method)

at com.google.android.gms.ads.internal.request.ab.a(SourceFile:101)

at com.google.android.gms.ads.internal.request.s.a(SourceFile:187)
at com.google.android.gms.ads.internal.request.s.a(SourceFile:164)
at com.google.android.gms.ads.internal.util.b.run(SourceFile:17)
at com.google.android.gms.ads.internal.util.d.call(SourceFile:29)
at com.google.android.gms.ads.internal.util.e.call(SourceFile:49)

at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)

at java.lang.Thread.run(Thread.java:841)
There was a problem getting an ad response. ErrorCode: 0
Failed to load ad: 0

我已经尝试过重新排列代码,但我尝试过的任何内容都不会改变结果。例如,我尝试使用AdListener并将其附加到InterstitialAd对象并覆盖onAdClosed方法,然后尝试请求下一个广告。

有人有什么想法吗?

0 个答案:

没有答案