phaserNOOB Posted September 27, 2014 Share Posted September 27, 2014 I have built a game in phaser (html5) , and packed it using crosswalk because the webview kit on versions below kitkat are not able to run the app properly. So I used intel xdk and crosswalk to build my apk. It worked perfect for me. But this being my first android project I am not familiar with monetizing techniques. I tried admob integration using cordova plugin , but the ads dont show up. Needed help with that.heres my index.html <!DOCTYPE HTML><html><head><meta charset="utf-8"><title>xyz</title><script src="libs/phaser.min.js"></script><meta name="mobile-web-app-capable" content="yes"><meta name="viewport" content="width=device-width"><script src="Boot.js"></script><script src="MainMenu.js"></script><script src="PlayGame.js"></script><script src="PostGame.js"></script><script src="HighScores.js"></script><script src="Help.js"></script><script src="about.js"></script><script type="text/javascript" src="cordova.js"></script><style type="text/css">body {width: 100%;height: 100%;margin: 0;padding: 0;overflow: hidden;background-color: gray;color: white;}div#fullpage {width: 100%;height: 100%;margin: 0;padding: 0;border: 0px solid red;text-align: center;vertical-align: middle;}button {font-size: 18px;}</style></head><body onload="onLoad()" onresize="onResize()"><script>function onLoad() {if(( /(ipad|iphone|ipod|android)/i.test(navigator.userAgent) )) {document.addEventListener('deviceready', initApp, false);} else {initApp();}}var ad_units = {android : {banner: 'ca-app-pub-6128098175931507/1770967078',interstitial: 'ca-app-pub-6128098175931507/3097766271'}};var admobid = ( /(android)/i.test(navigator.userAgent) ) ? ad_units.android : ad_units.android;function initApp() {if (! AdMob ) { alert( 'admob plugin not ready' ); return; }initAd();// display the banner at startupAdMob.createBanner( admobid.banner, function(){}, function(data){alert(JSON.stringify(data));} );}function initAd(){var defaultOptions = {bannerId: admobid.banner,interstitialAdId: admobid.interstitial,adSize: 'SMART_BANNER',// width: integer, // valid when set adSize 'CUSTOM'// height: integer, // valid when set adSize 'CUSTOM'position: AdMob.AD_POSITION.BOTTOM_CENTER,// x: integer, // valid when set position to 0 / POS_XY// y: integer, // valid when set position to 0 / POS_XYisTesting: false, // set to true, to receiving test ad for testing purposeautoShow: true // auto show interstitial ad when loaded, set to false if prepare/show};AdMob.setOptions( defaultOptions );}</script><style>body {padding: 0;margin: 0;background-color: #FFFFFF;}</style></head><body><div id="Game container"></div><script type="text/javascript">window.onload = function() {var game = new Phaser.Game( 675, 1200, Phaser.Auto, "Game container");game.state.add('Boot', xyz.Boot);game.state.start('Boot'); // Boots the game using the mainmenu.js method() which also calls the preloader()}</script> </body></html> Link to comment Share on other sites More sharing options...
Robske Posted September 29, 2014 Share Posted September 29, 2014 Check out the Android device logs. It should tell you about the AdMob ads being loaded and *why* they are not displayed. Link to comment Share on other sites More sharing options...
valueerror Posted November 9, 2014 Share Posted November 9, 2014 any luck with that? does it alert "admob plugin not ready" ??how are you loading the admob plugin? which admob plugin are you trying to load and how? using intel xdk? or console? you may connect your device to your pc and use intel xdk to debug (push) your app to the device and then klick on the "bug" icon to start the chrome console and read the debug messages.. oh.. and in intel xdk - ads will NOT work unless you compile the project and actually run it on your device.. testing/debugging does not load the plugin ^^ Link to comment Share on other sites More sharing options...
Vii Posted January 11, 2017 Share Posted January 11, 2017 dude your html is fck up!! got 2opening body tags Link to comment Share on other sites More sharing options...
bruno_ Posted January 11, 2017 Share Posted January 11, 2017 I was having an error in: if (!Admob) Changed to: if(!window.AdMob) and it worked, but it may be a different case, you should see the logs with adb logcat Link to comment Share on other sites More sharing options...
Vii Posted January 11, 2017 Share Posted January 11, 2017 9 minutes ago, bruno_ said: I was having an error in: if (!Admob) Changed to: if(!window.AdMob) and it worked, but it may be a different case, you should see the logs with adb logcat how did you make interstitial work after state? Link to comment Share on other sites More sharing options...
bruno_ Posted January 11, 2017 Share Posted January 11, 2017 I'm not sure I understood your question. What do you mean after state? I used the sample in the plugin repo: https://github.com/floatinghotpot/cordova-admob-pro/blob/master/README.md Link to comment Share on other sites More sharing options...
Recommended Posts