Problem with released build of html5 game with google IMA sdk

Problem with released build of html5 game with google IMA sdk
0.0 0

#1

Hello there, I’ve developed a game in cocos2d-js html5 . In this game I integrate google’s IMA sdk https://developers.google.com/interactive-media-ads/docs/sdks/html5/ for showing ads. If I upload whole 550 mb size project on server then game and ads are coming proper.

But when I create it’s release build and upload the publish folder then following error comes.

Error: google.Gd is undefined[Learn More] game.min.js:1148:15
uc http://localhost:8080//NaughtyHammerKid/publish/html5/game.min.js:1148:15
hc http://localhost:8080//NaughtyHammerKid/publish/html5/game.min.js:1147:342
http://localhost:8080//NaughtyHammerKid/publish/html5/game.min.js:1152:133

line no 1147 is as follow-

function nc(){mc=!1;b.I.C6()}var dc=function(){b.log(“play item has been pressed”);mc=!1;var a=new nb;b.I.Hd(a)},cc=b.De.extend({ea:function(){this._super();if(!1==mc){mc=!0;var a=new oc;this.D(a)}}});var pc,qc,rc,sc,tc;function hc(){document.getElementById(“mainContainer”).style.display=“none”;tc=document.getElementById(“contentElement”);uc()}

line no 1148 is as follow-

function uc(){rc=new google.Gd.U9(document.getElementById(“adContainer”),tc);qc=new google.Gd.V9(rc);qc.addEventListener(google.Gd.W9.df.B9,vc,!1);qc.addEventListener(google.Gd.gU.df.cU,wc,!1);tc.gla=function(){qc.nea()};var a=new google.Gd.Y9;a.sda=“https://googleads.g.doubleclick.net/pagead/ads?ad_type\x3dvideo_image\x26client\x3dca-games-pub-4968145218643279\x26videoad_start_delay\x3d0\x26description_url\x3dhttp%3A%2F%2Fwww.google.com\x26max_ad_duration\x3d20000\x26adtest\x3don”;a.Xfa=!0;a.rka=

line no 1152 is as follow-

“none”,c.$y()&&clearInterval(sc)}}function wc(a){console.log(a.getError());pc.w2()}function xc(){tc.pause()}function yc(){tc.play()}hc();b.t.Vq=function(){!b.xa.A5&&document.getElementById(“cocosLoading”)&&document.body.removeChild(document.getElementById(“cocosLoading”));b.view.OP(b.xa.Hm===b.xa.es?!0:!1);b.view.o1(!0);b.view.lr(800,480,b.Bf.SHOW_ALL);b.view.d7(!0);b.JA.F6(function(){b.I.Hd(new mb)},this)};b.t.k7();

And following my ads.js file in which I write code for ads.

var adsManager;
var adsLoader;
var adDisplayContainer;
var intervalTimer;
var playButton;
var videoContent;

function init() {
document.getElementById(“mainContainer”).style.display = ‘none’; //
// document.getElementById(“playButton”).style.display = ‘none’;
videoContent = document.getElementById(‘contentElement’);
// playButton = document.getElementById(‘playButton’);
// playButton.addEventListener(‘click’, playAds);
setUpIMA();
}

function setUpIMA() {
// Create the ad display container.
createAdDisplayContainer();
// Create ads loader.
adsLoader = new google.ima.AdsLoader(adDisplayContainer);
// Listen and respond to ads loaded and error events.
adsLoader.addEventListener(
google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED,
onAdsManagerLoaded,
false);
adsLoader.addEventListener(
google.ima.AdErrorEvent.Type.AD_ERROR,
onAdError,
false);

// An event listener to tell the SDK that our content video
// is completed so the SDK can play any post-roll ads.
var contentEndedListener = function() {adsLoader.contentComplete();};
videoContent.onended = contentEndedListener;

// Request video ads.
var adsRequest = new google.ima.AdsRequest();
/* adsRequest.adTagUrl = 'https://pubads.g.doubleclick.net/gampad/ads?’ +
‘sz=640x480&iu=/124319096/external/single_ad_samples&ciu_szs=300x250&’ +
‘impl=s&gdfp_req=1&env=vp&output=vast&unviewed_position_start=1&’ +
‘cust_params=deployment%3Ddevsite%26sample_ct%3Dlinear&correlator=’; */

  adsRequest.adTagUrl = 'https://googleads.g.doubleclick.net/pagead/ads?ad_type=video_image&client=ca-games-pub-4968145218643279&videoad_start_delay=0&description_url=http%3A%2F%2Fwww.google.com&max_ad_duration=20000&adtest=on';

// Specify the linear and nonlinear slot sizes. This helps the SDK to
// select the correct creative if multiple are returned.
adsRequest.forceNonLinearFullSlot = true;
adsRequest.linearAdSlotWidth = 640;
adsRequest.linearAdSlotHeight = 400;

adsRequest.nonLinearAdSlotWidth = 640;
adsRequest.nonLinearAdSlotHeight = 150;

adsLoader.requestAds(adsRequest);
}

function createAdDisplayContainer() {
// We assume the adContainer is the DOM id of the element that will house
// the ads.
adDisplayContainer = new google.ima.AdDisplayContainer(
document.getElementById(‘adContainer’), videoContent);
}

function playAds() {
document.getElementById(“mainContainer”).style.display = ‘block’;
cc.log(“playAds”);
// Initialize the container. Must be done via a user action on mobile devices.
videoContent.load();
adDisplayContainer.initialize();

try {
// Initialize the ads manager. Ad rules playlist will start at this time.
adsManager.init(640, 360, google.ima.ViewMode.NORMAL);
// Call play to start showing the ad. Single video and overlay ads will
// start at this time; the call will be ignored for ad rules.
adsManager.start();
} catch (adError) {
// An error may be thrown if there was a problem with the VAST response.
videoContent.play();
}
}

function onAdsManagerLoaded(adsManagerLoadedEvent) {
// Get the ads manager.
var adsRenderingSettings = new google.ima.AdsRenderingSettings();
adsRenderingSettings.restoreCustomPlaybackStateOnAdBreakComplete = true;
// videoContent should be set to the content video element.
adsManager = adsManagerLoadedEvent.getAdsManager(
videoContent, adsRenderingSettings);

// Add listeners to the required events.
adsManager.addEventListener(
google.ima.AdErrorEvent.Type.AD_ERROR,
onAdError);
adsManager.addEventListener(
google.ima.AdEvent.Type.CONTENT_PAUSE_REQUESTED,
onContentPauseRequested);
adsManager.addEventListener(
google.ima.AdEvent.Type.CONTENT_RESUME_REQUESTED,
onContentResumeRequested);
adsManager.addEventListener(
google.ima.AdEvent.Type.ALL_ADS_COMPLETED,
onAdEvent);

// Listen to any additional events, if necessary.
adsManager.addEventListener(
google.ima.AdEvent.Type.LOADED,
onAdEvent);
adsManager.addEventListener(
google.ima.AdEvent.Type.STARTED,
onAdEvent);
adsManager.addEventListener(
google.ima.AdEvent.Type.COMPLETE,
onAdEvent);
adsManager.addEventListener(
google.ima.AdEvent.Type.SKIPPED,
onAdEvent);
adsManager.addEventListener(
google.ima.AdEvent.Type.USER_CLOSE,
onAdEvent);
}

function onAdEvent(adEvent) {
// Retrieve the ad from the event. Some events (e.g. ALL_ADS_COMPLETED)
// don’t have ad object associated.
var ad = adEvent.getAd();
switch (adEvent.type) {
case google.ima.AdEvent.Type.LOADED:
// This is the first event sent for an ad - it is possible to
// determine whether the ad is a video ad or an overlay.
if (!ad.isLinear()) {
// Position AdDisplayContainer correctly for overlay.
// Use ad.width and ad.height.
videoContent.play();
}
else {

    }
  break;
case google.ima.AdEvent.Type.STARTED:
  // This event indicates the ad has started - the video player
  // can adjust the UI, for example display a pause button and
  // remaining time.
  if (ad.isLinear()) {
    // For a linear ad, a timer can be started to poll for
    // the remaining time.
    intervalTimer = setInterval(
        function() {
          var remainingTime = adsManager.getRemainingTime();
        },
        300); // every 300ms
  }
  break;
case google.ima.AdEvent.Type.COMPLETE:
  // This event indicates the ad has finished - the video player
  // can perform appropriate UI actions, such as removing the timer for
    // remaining time detection.
    //    document.getElementById("contentElement").style.display = 'none';
    document.getElementById("mainContainer").style.display = 'none';
  if (ad.isLinear()) {
    clearInterval(intervalTimer);
  }
  break;
  case google.ima.AdEvent.Type.SKIPPED:
      cc.log("SKIPPED");
      // This event indicates the ad has finished - the video player
      // can perform appropriate UI actions, such as removing the timer for
      // remaining time detection.
     // document.getElementById("contentElement").style.display = 'none';
      document.getElementById("mainContainer").style.display = 'none';
      if (ad.isLinear()) {
          clearInterval(intervalTimer);
      }
      break;
  case google.ima.AdEvent.Type.USER_CLOSE:
      // This event indicates the ad has finished - the video player
      // can perform appropriate UI actions, such as removing the timer for
      // remaining time detection.
      cc.log("USER_CLOSE");
     // document.getElementById("contentElement").style.display = 'none';
      document.getElementById("mainContainer").style.display = 'none';
      if (ad.isLinear()) {
          clearInterval(intervalTimer);
      }
      break;

}
}

function onAdError(adErrorEvent) {
// Handle the error logging.
console.log(adErrorEvent.getError());
adsManager.destroy();
}

function onContentPauseRequested() {
videoContent.pause();
// This function is where you should setup UI for showing ads (e.g.
// display ad timer countdown, disable seeking etc.)
// setupUIForAds();
}

function onContentResumeRequested() {
videoContent.play();
// This function is where you should ensure that your UI is ready
// to play content. It is the responsibility of the Publisher to
// implement this function when necessary.
// setupUIForContent();

}

// Wire UI element references and UI event listeners.
init();

Please help me why in release build I’m getting error.
Thanks.