I am trying to add Admob ads into my game. I have used the below code which is taken from the SDKBOX cocos creator tutorial.
admobInit: function() {
if(cc.sys.isMobile) {
var self = this
sdkbox.PluginAdMob.setListener({
adViewDidReceiveAd: function(name) {
self.showInfo('adViewDidReceiveAd name=' + name);
},
adViewDidFailToReceiveAdWithError: function(name, msg) {
self.showInfo('adViewDidFailToReceiveAdWithError name=' + name + ' msg=' + msg);
},
adViewWillPresentScreen: function(name) {
self.showInfo('adViewWillPresentScreen name=' + name);
},
adViewDidDismissScreen: function(name) {
self.showInfo('adViewDidDismissScreen name=' + name);
},
adViewWillDismissScreen: function(name) {
self.showInfo('adViewWillDismissScreen=' + name);
},
adViewWillLeaveApplication: function(name) {
self.showInfo('adViewWillLeaveApplication=' + name);
}
});
sdkbox.PluginAdMob.init();
}
},
cacheInterstitial: function() {
if(cc.sys.isMobile) {
sdkbox.PluginAdMob.cache('gameover');
}
},
showInterstitial: function() {
if(cc.sys.isMobile) {
sdkbox.PluginAdMob.show('gameover');
}
},
The admobInit function is called in onLoad. I have changed the ad ID in the sdkbox.config file to the test ones from the Admob website. This game has a two scenes, one first which just has a button which leads to the next scene which contains the admob code. I’ve built it and installed it on my Android tablet. When run the first scene works fine. Clicking the button which leads to the scene with admob ads makes the app crash. I just get a black screen.
Is there anything else that needs to be done to make the ads work?
Anything else that has to be changed in the project files?
Does the app automatically connect to the internet or does that have to be enabled somewhere?
If anyone can help that would be great.