I’m fairly new to Cocos2dx. Loving it so far! Thanks to all who have made it possible!
The Mopub integration instructions suggest creating the ad view in xml with a snippet like this:
Then the instructions suggest creating the ad view in the activity’s create method like this:
moPubView = (MoPubView)findViewById(R.id.adview); moPubView.setAdUnitId("123412341234"); moPubView.loadAd();
moPubView is not created. I think this is because Cocos2dx 2.1 doesn’t use XML for layout anymore(?) So the app crashes on launch due to a null pointer exception.
I tried passing
setContentView before attempting to create the ad view. This does successfully create the ad view however the rest of the app isn’t visible.
Anyone have advice on how to solve this in Cocos2dx 2.1?
One thought I have is creating the view programmatically instead of using XML. However after some research it looks like I still need to call
setContentView. I’m worried I’ll run into the same problem as above hence I thought I’d ask here.
This conversation seems to be talking about the same thing: https://github.com/mopub/mopub-client/issues/85