AdMob for android crashes the app

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.

plz check this one Cocos creator sdkbox integration error

Hi, thanks for replying.

I tried adding those lines to the AppDelegate.cpp file however when I compiled the game it failed. The error log was having problems with those lines added to the AppDelegate. Do those lines have to be put in a certain place in the AppDelegate for it to work?
Also what about adding the SDKBoxads lines as well. Now that admob is grouped into SDKBoxads and not stand alone does that have to be included as well?

Sorry I don’t understand all this that well. I’m using Cocos Creator 1.9.0 and using the built in SDKBox launcher to install the plugins. Could that be a possible issue?

Thanks again. :sweat_smile: