Search code examples
javascriptcordovagoogle-ima

google ima script not loading in Cordova application


I am working on android application wrapped w/ Cordova. The application uses google ima to display ads : Google IMA

When I try to reference any functions e.g :

adDisplayContainer =  new google.ima.AdDisplayContainer(document.getElementById('adContainer'));

I get the following error: "ReferenceError: google is not defined".

I have a script tag with src="http://imasdk.googleapis.com/js/sdkloader/ima3.js" in the body of index.html. I have tried it in the head as well.


Solution

  • I specified a protocol and ran "cordova build android" and that seem to have done the trick.

    I have tried using a src with no protocol as well src="http://imasdk.googleapis.com/js/sdkloader/ima3.js"