Plugin-X Admob Cocos2d-x 3

Hi, anyone can help me how can i implement admob on cocos2d-x3
i try the sample HelloPlugins it run but not work the plugin, segmentation fault raise (logcat)

thanks

I solved, i put the *.jar from plugins/ on libs/ on my android project and everything works…

Hey, I am trying to implement admob in my game. But I am getting a lot of problems with the JNI and other things that I don’t understand completely.

a) About what .jar are you talking, the one of the admob sdk or the one that is created by cocos? I mean GoogleAdMobAdsSdk.jar or libPluginAdmob.jar

b) Do you write any code inside the main.cpp file?

c) What guide did you follow to implement it, for me HelloPlugins don’t work on my device, and I’m working with the same code of it but nothing, all I get is errors.

Thanks

Don’t worry, I have solve it!

Haaa… ok
but for history:
* copy jar cocos2d-x/plugin/publish/protocols/android/libPluginProtocol.jar
* then copy then jar for the plugin used Admob, cocos2d-x/plugin/publish/plugins/admob/android/GoogleAdMobAdsSdk.jar, cocos2d-x/plugin/publish/plugins/admob/android/libPluginAdmob.jar
* all before to proj.android/libs/

inside de main.cpp (android only) put:
head

 #include "PluginUtils.h"

body, inside body

cocos_android_app_init(){
 ..
 cocos2d::plugin::PluginUtils::initPluginWrapper(app);
 ..
}

and, for show admob on Classes/.ccp:
first, create a
AdsListener*

#include "ProtocolAds.h"
#include "PluginManager.h"

class MyAdsListener : public cocos2d::plugin::AdsListener {
  //Ads
  virtual void onAdsResult(cocos2d::plugin::AdsResultCode code, const char* msg) {}
  virtual void onPlayerGetPoints(cocos2d::plugin::ProtocolAds* pAdsPlugin, int points) {}
};

i puts this on AppDelegate.cpp:

cocos2d::plugin::TAdsDeveloperInfo devInfo;
devInfo["AdmobID"] = XXXXXXXXX; /*my id*/
cocos2d::plugin::ProtocolAds* admob =  dynamic_cast(cocos2d::plugin::PluginManager::getInstance()->loadPlugin("AdsAdmob"));
cocos2d::plugin::AdsListener* listener = new MyAdsListener();
cocos2d::plugin::ProtocolAds::AdsPos posAdmob = cocos2d::plugin::ProtocolAds::kPosTopLeft;
cocos2d::plugin::TAdsInfo adInfo;
admob->configDeveloperInfo(devInfo);
admob->setAdsListener(listener);
admob->setDebugMode(false);
adInfo["AdmobType"] = "1";
adInfo["AdmobSizeEnum"] = "1";
admob->showAds(adInfo, posAdmob);

and, for understanding better look:
cocos2d-x/plugin/samples/HelloPlugins/Classes/TestAds/*…

I downloaded cocos2d-x 3 but I can’t find libPluginAdmob.jar and libPluginProtocol.jar.
Where I can download these files?

Thanks

I have this problem too.

Where I can get these .jar files?

Thanks.

@dkt2008 wrote:

I downloaded cocos2d-x 3 but I can’t find libPluginAdmob.jar and libPluginProtocol.jar.
Where I can download these files?

Thanks

Yea,Since is missing,have latest note review?

Try update submodules:
place on root dir cocos2d and run:
git submodule update --init

then build the plugins:
./cocos2d-x/plugin/tools/publish.sh

and you have the .jar:
cocos2d-x/plugin/publish/plugins/

you need also need this jar:
cocos2d-x/plugin/protocols/android/libPluginProtocol.jar

before i try build for android, i need change the file build_native and replace:
ndk_module_path = ‘NDK_MODULE_PATH=%s:%s/external:%s/cocos’ % (cocos_root, cocos_root, cocos_root)
FOR
ndk_module_path = ‘NDK_MODULE_PATH=%s:%s/external:%s/cocos:%s/plugin/publish’ % (cocos_root, cocos_root, cocos_root,cocos_root)

Hello,
where is my id in :
devInfo[“AdmobID”] = XXXXXXXXX; /my id/

I just have ca-app-pub-xxxxxxxxxxxxxxxxxxxxxx in admob website.

thx.

Plugin-X in Cocos2d V3.3:

It seems that it’s deprecated for Android, since it doesn’t use the GooglePlay Service API.

Any thoughts?

This is updated in the 3.3 version. BTW, they changed from:

void cocos_android_app_init( android_app* app....){

To this signature:

void cocos_android_app_init (JNIEnv* env, jobject thiz) {

Any idea how to get it working nowadays?

@zhen Pluxin-X in V3.3 doesn’t use the Google Play services SDK. Therefore you can’t submit a new app on Google Play with this plugin.

I wrote a complete tutorial for how to integrate Admob in Cocos2d-x v3.4 by using plugin-x. (OS X)

Admob integration in Cocos2d-x v3.4 with plugin-x

Enjoy it ~~

4 Likes

Thank you Neokoala, you make my day.
It’s not relevent here but i wondering could you write a tutorial about integrate Facebook in cocos2d-x v3.4 using plugin-x, or tutorial about Plugin-x, couldn’t you ? (I’m not clearly understand about Plugin-x so it’s hard for me to integrate it on my project.)
And again, thank you so much.

1 Like

@neokoala thanks a lot, easy to follow tutorial with lots of screens.

@LamH +1

@LamH , @Greenhouse

Glad this tutorial helped you.
I’ll do the Facebook intergration tutorial when I have a time.

Can I use this tutorial also for adding admob in cocos2d-x 3.4 lua? The only thing I need to change is call he plugin-x stuff in lua, right?

I haven’t developed in lua before, so I cannot say ^^;

@neokoala I am having another question. This PR https://github.com/cocos2d-x/plugin-x/pull/99 mentions that the admob plugin for plugin-x is using old api and isn’t working anymore. The PR would update the plugin for using new api.

Is your github repository using old or new api?

Thanks!