[SOLVED] Cocos creator 1.6 SDKBox

[SOLVED] Cocos creator 1.6 SDKBox
0.0 0

#1

I try to add AdMob to my application in cocos creator 1.6. I did it along this tutorial: http://docs.sdkbox.com/en/qa/cocos_creator/ but I’m getting error if I try to run the simulator:

JS Exception- sdkbox is not defined.

It is possible to build application for android, but it show just only black screen. I guess it is due to the error.

Is there necessary to setup anything manually or it is just bug in this release?

Thanks for answers. Petr


#2

you need to compile the simulator again, because added some native code.


#3

How can I compile simulator?
Otherwise I don’t think so that is just problem of simulator because if I compile the code for Android and run it in a device there is same blackscreen problem.


#4

plz make sure there are some js register int file AppDelegate.cpp , such as

#ifdef SDKBOX_ENABLED
    sc->addRegisterCallback(register_all_PluginIAPJS);
    sc->addRegisterCallback(register_all_PluginIAPJS_helper);
    sc->addRegisterCallback(register_all_PluginFacebookJS);
    sc->addRegisterCallback(register_all_PluginFacebookJS_helper);
#endif

#5

Yes the AppDelegate.cpp file looks OK.

    js_module_register();
    
    ScriptingCore* sc = ScriptingCore::getInstance();
#ifdef SDKBOX_ENABLED
    sc->addRegisterCallback(register_all_PluginAdMobJS);
    sc->addRegisterCallback(register_all_PluginAdMobJS_helper);
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && PACKAGE_AS    
    sc->addRegisterCallback(register_all_anysdk_framework);
    sc->addRegisterCallback(register_all_anysdk_manual);
#endif
    ScriptEngineManager::getInstance()->setScriptEngine(sc);
    sc->start();
    sc->runScript("script/jsb_boot.js");
    sc->runScript("main.js");
    
    return true;

#6

I think that problem isn’t with each module but with whole SDKBox.

Simulator: ------------------------------------------------
Simulator: Cocos2d-x-lite v1.6.0
Simulator: iShow!
Simulator: InitScene: 20.580999999999904ms
Simulator: AutoRelease: 1.7040000000001783ms
Simulator: Destroy: 0.42399999999997817ms
Simulator: AttachPersist: 0.027000000000043656ms
Simulator: JS Exception: sdkbox is not defined, file: C:/Users/Petr/Documents/NewProject/temp/quick-scripts/assets/Script/AdMob.js, lineno: 18
Simulator: 

my AdMob.js file:

cc.Class({
	extends: cc.Component,
	
	properties: {
		
	},
	
	showText: function(str) {
        console.log('usr log:' + str);
    },
	
    onLoad: function () {
            var self = this
            sdkbox.PluginAdMob.setListener({
                adViewDidReceiveAd: function(name) {
                    self.showText('adViewDidReceiveAd name=' + name);
                },
                adViewDidFailToReceiveAdWithError: function(name, msg) {
                    self.showText('adViewDidFailToReceiveAdWithError name=' + name + ' msg=' + msg);
                },
                adViewWillPresentScreen: function(name) {
                    self.showText('adViewWillPresentScreen name=' + name);
                },
                adViewDidDismissScreen: function(name) {
                    self.showText('adViewDidDismissScreen name=' + name);
                },
                adViewWillDismissScreen: function(name) {
                    self.showText('adViewWillDismissScreen=' + name);
                },
                adViewWillLeaveApplication: function(name) {
                    self.showText('adViewWillLeaveApplication=' + name);
                }
            });
            sdkbox.PluginAdMob.init();
    },

    cacheInterstitial: function() {
        if(cc.sys.isMobile) {
            sdkbox.PluginAdMob.cache('gameover');
        }
    },

    showInterstitial: function() {
		var self = this
		self.showText('is not mobile');
        if(cc.sys.isMobile) {
			self.showText('is mobile');
            sdkbox.PluginAdMob.show('gameover');
        }
    },


});

#7

sdkbox plugin is design for mobile platform, can not run on pc/mac platform.


#8

Yes I want to run it on Android mobile phone. But there is same problem as in simulator.

BTW simulator is like a mobile device or as a Windows system?


#9

I solve it, There was a problem with a default template. I switched to a binary template and it seems that it is working good.


#10

@petrdake Have you test on Mobile device? For me on android, it compiles successfully by choosing binary template but the game show black screen.


#11

whats the logcat error?


#12

Yes I tested it on Android. If you have blackscreen you have error in your code.


#13

Did you try it using creator 1.7?


#14

Hello i am having this same problem, i use a binary template, i run on android, the app just shows a black screen and closes