Using Admob with LUA

I am following this “how to”

http://www.cocos2d-x.org/wiki/User_Tutorial-Integrate_AdMob

but it is for C++ , is there any “how to” with LUA version?

The big problem is that yo have to include the C++ file in the .mk

But in the how to of binding LUA the C++ should be in another part

Can someone help me?

Thank you.

I found a very good tutorial admod for LUA, I implemented, follow the link: http://qiita.com/YukiMiyatake/items/c861ec4b5bb3069db0c6

Does the solution work for Cocos 3.3?

In V3.3,plugin->samples->HelloPluginsLua has test cases for AdsAdmob,the related script file is TestAdsScene.lua

Thank you very much for the response.

However, I’m quite a novice and I was unable to run the examples from this folder properly.
I’ve imported HelloPluginsLua into Cocos Code IDE.
I’ve managed to run it on my device (However, only after modifying my AppDelegate.cpp, Android.mk etc).
I’ve got a black screen with a lot of choices: facebook, ads, etc but when I press them, they just didn’t function.
I remember that it was unable to find classes like plugin or plugin.PluginManager…

Moreover, I was unable to find any manual on how to prepare the project to run these examples with Lua. There is only a kind of manual for C++ samples (https://github.com/cocos2d-x/plugin-x/wiki/Sample).

BTW I’m working under Windows and for Android devices.

I’m trying to use the sample but I am having a problem with

self.admob = plugin.PluginManager:getInstance():loadPlugin("AdsAdmob")

If I put that in my project “plugin” is not defined

and I can’t find anything about plugin in the sample
so… what I have to do to define/import/reference “plugin”?

Did you import the lua bindings files in the plugin\luabindings and call the register functions?

How is the process for importing that? I am looking the sample of plugin-x and I can’t find where inside the lua files imports the plugin.

And the file lua_plugin.lua only contains a reference to facebook.

The plugin-x module is imported in the AppDelegate::applicationDidFinishLaunching() by calling

    register_all_pluginx_protocols(luaState);
    register_all_pluginx_manual_callback(luaState);
    register_all_pluginx_manual_protocols(luaState);

Ok, I’ve modified AppDelegate, Android.mk…

and now I’m receiving errors:

jni/../../../cocos2d-x/plugin/luabindings/manual/lua_pluginx_manual_callback.cpp: In function 'int lua_pluginx_protocols_FacebookAgent_login(lua_State*)':
jni/../../../cocos2d-x/plugin/luabindings/manual/lua_pluginx_manual_callback.cpp:778:66: error: 'tolua_err' was not declared in this scope
             if (!toluafix_isfunction(tolua_S,2,"LUA_FUNCTION",0,&tolua_err))
                                                                  ^
jni/../../../cocos2d-x/plugin/luabindings/manual/lua_pluginx_manual_callback.cpp:800:66: error: 'tolua_err' was not declared in this scope
             if (!toluafix_isfunction(tolua_S,3,"LUA_FUNCTION",0,&tolua_err))
                                                                  ^
At global scope:
cc1plus.exe: warning: unrecognized command line option "-Wno-extern-c-compat" [enabled by default]
cc1plus.exe: warning: unrecognized command line option "-Wno-extern-c-compat" [enabled by default]
make.exe: *** [obj/local/armeabi/objs/cocos2dlua_shared/__/__/__/cocos2d-x/plugin/luabindings/manual/lua_pluginx_manual_callback.o] Error 1

any news? I am trying to use plugin-x too…

I think I am really close using plugin-x in lua…
It compiles but I get following errors.

[armeabi] StaticLibrary : libcocos2dandroid.a
[armeabi] SharedLibrary : libcocos2dlua.so
D:/Development/android/ndk/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/…/lib/gcc/arm-linux-androideabi/4.9/…/…/…/…/arm-linux-androideabi/bin/ld.exe: error: D:/Development/android/ndk/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/…/lib/gcc/arm-linux-androideabi/4.9/thumb/libgcc.a(pr-support.o): multiple definition of ‘_Unwind_GetRegionStart’
D:/Development/android/ndk/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/…/lib/gcc/arm-linux-androideabi/4.9/…/…/…/…/arm-linux-androideabi/bin/ld.exe: D:/Development/android/ndk/android-ndk-r10d/sources/cxx-stl/llvm-libc++/libs/armeabi/thumb/libc++_static.a(Unwind-EHABI.o): previous definition here
D:/Development/android/ndk/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/…/lib/gcc/arm-linux-androideabi/4.9/…/…/…/…/arm-linux-androideabi/bin/ld.exe: error: D:/Development/android/ndk/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/…/lib/gcc/arm-linux-androideabi/4.9/thumb/libgcc.a(pr-support.o): multiple definition of ‘_Unwind_GetLanguageSpecificData’
D:/Development/android/ndk/android-ndk-r10d/toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/…/lib/gcc/arm-linux-androideabi/4.9/…/…/…/…/arm-linux-androideabi/bin/ld.exe: D:/Development/android/ndk/android-ndk-r10d/sources/cxx-stl/llvm-libc++/libs/armeabi/thumb/libc++_static.a(Unwind-EHABI.o): previous definition here
jni/…/…/Classes/AppDelegate.cpp:70: error: undefined reference to ‘register_all_pluginx_protocols(lua_State*)’
jni/…/…/Classes/AppDelegate.cpp:71: error: undefined reference to ‘register_all_pluginx_manual_callback(lua_State*)’
jni/…/…/Classes/AppDelegate.cpp:72: error: undefined reference to ‘register_all_pluginx_manual_protocols(lua_State*)’
collect2.exe: error: ld returned 1 exit status
make.exe: *** [obj/local/armeabi/libcocos2dlua.so] Error 1

Any idea?

edit
The publish.sh is creating some libPluginProtocolStatic.a.
I know I need to do something with this file.

Mm… I still can’t compile :-/

I did gave up on this.