AdMob error in Cocos Creator 1.9.1

AdMob error in Cocos Creator 1.9.1
0

#1

Hi, developing team.
I updated latest creator version 1.9.1 and link admob to my game.
I compiled it successfully but it shows black screen on device.

error message is following.

E/jswrapper: ERROR: Uncaught TypeError: Cannot read property 'setListener' of undefined, location: src/project.js:0:0
             STACK:
             [0]onLoad@src/project.js:43214
             [1]anonymous@(no filename):3
             [2]invoke@src/jsb_polyfill.js:3508
             [3]activateNode@src/jsb_polyfill.js:11669
             [4]_activate@src/jsb_polyfill.js:2336
             [5]runSceneImmediate@src/jsb_polyfill.js:21602
             [6]anonymous@src/jsb_polyfill.js:21694
             [7]anonymous@src/jsb_polyfill.js:13737
             [8]anonymous@src/jsb_polyfill.js:10225
             [9]anonymous@src/jsb_polyfill.js:16575
             [10]c@src/jsb_polyfill.js:9374
             [11]77.n.invoke@src/jsb_polyfill.js:9267
             [12]78.l.emit@src/jsb_polyfill.js:9432
             [13]callback@src/jsb_polyfill.js:21734
             [ERROR] (D:/SelfPub/TinkerPuzzle/build/jsb-default/frameworks/cocos2d-x/cocos/scripting/js-bindings/proj.android/../jswrapper/v8/Object.cpp, 519): Invoking function (0xee8b3ee0) failed!

my source code corresponding to this error is following.

    if(cc.sys.isMobile) {
        sdkbox.PluginAdMob.setListener({
            adViewDidReceiveAd: function(name) {},
            adViewDidFailToReceiveAdWithError: function(name, msg) {},
            adViewWillPresentScreen: function(name) {},
            adViewDidDismissScreen: function(name) {},
            adViewWillDismissScreen: function(name) {},
            adViewWillLeaveApplication: function(name) {}
        });
        sdkbox.PluginAdMob.init();
    }

I had the issue like this at creator 1.7 but I fixed it following Cocos creator sdkbox integration error

I checked AppDelegate.cpp file and added codes pointed out above.
So frustrate for the Cocos Creator, whenever it is version up, new issues already fixed occur.
Please help me.


#2

i’m checking on this issue.

UPDATE:
plz manually add bellow codes to AppDelegate.cpp again,

#ifdef SDKBOX_ENABLED
#include "PluginAdMobJS.hpp"
#include "PluginAdMobJSHelper.h"
#endif
#ifdef SDKBOX_ENABLED
se->addRegisterCallback(register_all_PluginAdMobJS);
se->addRegisterCallback(register_all_PluginAdMobJS_helper);
#endif

I’m so sorry for the inconvenience, this issue will be fixed with 2.4.0.1, and the new release be release 05.22 or 05.23.
Thanks,


#3

These code already added when it compiled.
So strange.

At 1.7, 1.8 if I add these code, issue was fixed .
At 1.9.1 even it is added automatically but it is not fixed.


#4

I checked AdMob with Creator 1.9.1, iOS. It works.
I’ll check on Android.


#5

I found the issue on android.


#6

Plugin AdMob with creator 1.9.1 on Android is also ok for me.
I want to figure out what’s the problem here.

  1. Have you recompiled the project after import admob ?
  2. Works on iOS ?
  3. Would you like to show the Android.mk ?

#7
  1. Have you recompiled the project after import admob ?
    Yes.
  2. Works on iOS ?
    No, I am working only on android.
  3. Would you like to show the Android.mk ?
    Yes, I will attach it.files.zip (2.0 KB)

#8

same as mine.

I want you use cocos command to run the app

cd build/jsb-default
cocos run -p android
  1. what about the build/jsb-default/.cocos-project.json file:
{
  "engine_version": "Cocos2d-x-lite v1.8.2",
  "has_native": true,
  "project_type": "js",
  "projectName": "hello_world",
  "packageName": "org.cocos2d.helloworld"
}

It reports 1.8.2.


#9

.cocos-project.json file

{
“engine_version”: “Cocos2d-x-lite v1.8.2”,
“has_native”: true,
“project_type”: “js”,
“projectName”: “TinkerPuzzle”,
“packageName”: “chy.kkuk.tinker”
}

If I run cocos run command, get error.

D:\SelfPub\TinkerPuzzle\build\jsb-default>cocos run -p android
Building mode: debug
Using Eclipse project : D:\SelfPub\TinkerPuzzle\build\jsb-default\frameworks\runtime-src\proj.android
ANT_ROOT not defined. Please define it in your environment.
D:\SelfPub\TinkerPuzzle\build\jsb-default>


#10

Did you not replicate this issue?


#11

no, I can not.

what’s your steps?

UP: trying Android Studio project.

UP2:

Would u please check your sdkbox command version by

$ sdkbox version
  _______ ______  _     _ ______   _____  _     _
  |______ |     \ |____/  |_____] |     |  \___/
  ______| |_____/ |    \_ |_____] |_____| _/   \_
 Copyright (c) 2016-2018 SDKBOX Inc. v1.0.1.35
 SDKBOX version 1.0.1.35

and plugin version is 2.4.0.1.

here is my test steps.

  1. remove build folder
  2. cmd + shift + b, checked SDKBox, and click build
  3. import AdMob in SDKBox panel.
  4. change minSdkVersion 14
  5. cmd + shift + b, click Compile, then click Play.

#12

Okay, I followed your guide.
The app work properly, but ads is not shown.

sdkbox.PluginAdMob.isAvailable(“gameover”);

this function return false always.
Thanks.


#13

Hi, did you check the admob shows ads?


#14

You can get some error with adViewDidFailToReceiveAdWithError: function(name, msg) {},,

    // use this for initialization
    onLoad: function () {
        this.label.string = this.text + "!!!";

        var self = this;
        if(cc.sys.isMobile) {
            sdkbox.PluginAdMob.setListener({
                adViewDidReceiveAd: function(name) { sdkbox.PluginAdMob.show(name); },
                adViewDidFailToReceiveAdWithError: function(name, msg) { self.label.string = msg; },
                adViewWillPresentScreen: function(name) {},
                adViewDidDismissScreen: function(name) {},
                adViewWillDismissScreen: function(name) {},
                adViewWillLeaveApplication: function(name) {}
            });
            sdkbox.PluginAdMob.init();
        }
    },

NTOE: you wont 100% get ad from AdMob.


#15

Hi
So what I have to do to show ads?
At the 1.7, 1.8, ads has been shown properly after I add this code.

#ifdef SDKBOX_ENABLED
#include “PluginAdMobJS.hpp”
#include “PluginAdMobJSHelper.h”
#endif
#ifdef SDKBOX_ENABLED
se->addRegisterCallback(register_all_PluginAdMobJS);
se->addRegisterCallback(register_all_PluginAdMobJS_helper);
#endif


#16

Is there any solution?
Please help me


#17

would you please share the test code in GitHub.com ? I’ll check it.
Thanks,