DFP Videos Ads Internal error

303 views Asked by At

I am going to develop a plugin for cordova to display video ads delivered by google dfp. It will be an Android app at the end. Wrapping HTML5 games for Google Play Store.

So I got this link to read the ad information for the plugin. In fact, that is reference with a shorter id like /232633/banner_video_foo.

With another id everything is working, showing a banner is no problem. Just for these stuff i got no clue what is going wrong.

PublisherAdView adView = new PublisherAdView(model.activity.getApplicationContext());
        AdSize customAdSize = new AdSize(400, 300);
        adView.setAdSizes(customAdSize);
        Log.d(TAG, "bannerId: " + model.bannerId);
        adView.setAdUnitId(model.bannerId);
        adView.setAppEventListener(this);

        adView.setAdListener(new AdListener() {


            @Override
            public void onAdLoaded() {
                Log.d(TAG, "onAdLoaded");
            }

            @Override
            public void onAdFailedToLoad(int errorCode) {
                Log.d(TAG, "onAdFailedToLoad: " + errorCode);
                String msg = "";
                if (errorCode == AdRequest.ERROR_CODE_INTERNAL_ERROR) msg = "ERROR_CODE_INTERNAL_ERROR";
                if (errorCode == AdRequest.ERROR_CODE_INVALID_REQUEST) msg = "ERROR_CODE_INVALID_REQUEST";
                if (errorCode == AdRequest.ERROR_CODE_NETWORK_ERROR) msg = "ERROR_CODE_NETWORK_ERROR";
                if (errorCode == AdRequest.ERROR_CODE_NO_FILL) msg = "ERROR_CODE_NO_FILL";

                Log.d(TAG, "onAdFailedToLoad: " + msg);
            }

            @Override
            public void onAdOpened() {
                Log.d(TAG, "onAdOpened");
            }

            @Override
            public void onAdClosed() {
                Log.d(TAG, "onAdClosed");
            }

            @Override
            public void onAdLeftApplication() {
                Log.d(TAG, "onAdLeftApplication");
            }
        });

        PublisherAdRequest adRequest = new PublisherAdRequest.Builder().build();

        ViewGroup vg = getViewGroup();
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
        AdSize size = adView.getAdSize();   
        params.leftMargin = (int)((vg.getWidth() - size.getWidthInPixels(model.activity.getApplicationContext()) ) * 0.5);  ;

        if (model.isBottom) {       
            params.topMargin = (int)(vg.getHeight() - size.getHeightInPixels(model.activity.getApplicationContext()));      
        }

        vg.addView(adView, params);

        adView.loadAd(adRequest);           
  return true;  
    }    

So that is my code wich is working for the banner but not for the video ads. There are html5 video ads. I am always getting an ERROR_CODE_INTERNAL_ERROR.

So i thougt may ba i just use the wrong classes. Then i tried the same id with Interstidials (PublisherInterstitialAd) but also same error.

Does any one knows how i can display these ads?

Update: Okay I just forgot to implement the IMA SDK! But now I am only able to use the link link version not the short one. does anyone knows how to use the short version in IMA?

0

There are 0 answers