HelloPluginsLua How To?

Dear Community,
I’m struggling with this for quite a long time.
At this point I’m using Cocos Code IDE under Windows for Android devices.
The problem is that HelloPluginsLua in my case does not work out of the box.
I went to the plugins directory.
I successfully executed genbindings-lua.py and publish.sh scripts.
I exported HelloPluginsLua to my Workspace, I’ve built a custom runtime and nothing works in the test App. When I click IAP, Ads e t c I get the following message in my logcat
[LUA-print] LUA ERROR: [string “TestIAPScene.lua”]:12: attempt to index global ‘plugin’ (a nil value)

How do I link my pluginx to Lua in Cocos Code IDE? Which Android.mk files should one change? Maybe copy some files from one directory to another?

I feel really sorry, plugin lua hasn’t been looked at for a while.

Maybe try to include /luabindings folder to your project?

@nalivai,Did you import the related lua-bingings file likes lua_cocos2dx_pluginx_autp.cpp, etc into your project, the calling the related register function like register_all_pluginx_protocols etc in some places. You could refer the HelloPluginsLua in detail

Actually, it is not that simple when one uses Cocos Studio IDE. I had to link a lot of stuff to make plugin for Admob work with lua. I’m not publishing any solution to my problem now because it is not finished.

I generated started with only a default Lua project with a Dog. I removed all the plugins except Admob from plugin folder. I linked the rest using all the possible instructions in the internet. And finally my plugin was recognized by Cocos IDE and runtime. But it was giving a Nil value for self.admob = plugin.PluginManager:getInstance():loadPlugin(“AdsAdmob”).

Finally rebuilding, relinking etc I managed to make this function work. But now I have probably purely Android issue.

When I run self.admob:showAds({AdmobType = “1”, AdmobSizeEnum = “1”}) in my program I get the following error message in my logcat:

02-05 23:22:15.341 19197-19212/org.cocos2dx.CocosLuaGameThree E/﹕ Device driver API match
Device driver API version: 23
User space API version: 23
02-05 23:22:15.341 19197-19212/org.cocos2dx.CocosLuaGameThree E/﹕ mali: REVISION=Linux-r3p2-01rel3 BUILD_DATE=Fri Mar 21 13:52:50 KST 2014
02-05 23:22:18.321 19197-19212/org.cocos2dx.CocosLuaGameThree E/AndroidRuntime﹕ FATAL EXCEPTION: GLThread 3324
Process: org.cocos2dx.CocosLuaGameThree, PID: 19197
java.lang.VerifyError: org/cocos2dx/plugin/AdsAdmob$1
at org.cocos2dx.plugin.AdsAdmob.showBannerAd(AdsAdmob.java:153)
at org.cocos2dx.plugin.AdsAdmob.showAds(AdsAdmob.java:108)
at org.cocos2dx.lib.Cocos2dxRenderer.nativeTouchesBegin(Native Method)
at org.cocos2dx.lib.Cocos2dxRenderer.handleActionDown(Cocos2dxRenderer.java:126)
at org.cocos2dx.lib.Cocos2dxGLSurfaceView$6.run(Cocos2dxGLSurfaceView.java:220)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1471)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)

Could you please comment on what could it be? If I’ll manage to run it, I’ll publish my way of building everything for everybody.

It’s actually invoking android code, so you’re really close. It’s hard to tell what’s going on from the logcat, my guess is that, it’s missing the admob jar file, Make sure to double check if you selected export the jar file if you’re building with eclipse.

Thank you.
But I already had a missing *.jar file, it was giving quite a straightforwad message, that it cannot find a certain class e t c

I’ll try to make a new project today from scratch. I think this should be some kind of double referencing of some jar, class or lib. Also, maybe I (accidentally) published the plugin with another version of java compared to the one I use for the whole project ( http://examples.javacodegeeks.com/java-basics/exceptions/java-lang-verifyerror-how-to-solve-verifyerror/ )

I’ll let everybody know.


UPD. I was not successful. I paid attention to the messages during the publish.sh execution:

jni/…/…/platform/android/ProtocolAds.cpp: In function ‘void cocos2d::plugin::Java_org_cocos2dx_plugin_AdsWrapper_nativeOnAdsResult(JNIEnv*, jobject, jstring, jint, jstring)’:
jni/…/…/platform/android/ProtocolAds.cpp:44:53: warning: ‘cocos2d::plugin::AdsListener* cocos2d::plugin::ProtocolAds::getAdsListener()’ is deprecated (declared at jni/…/…/include/ProtocolAds.h:134) [-Wdeprecated-declarations]
jni/…/…/platform/android/ProtocolAds.cpp: In function ‘void cocos2d::plugin::Java_org_cocos2dx_plugin_AdsWrapper_nativeOnPlayerGetPoints(JNIEnv*, jobject, jstring, jint)’:
jni/…/…/platform/android/ProtocolAds.cpp:71:53: warning: ‘cocos2d::plugin::AdsListener* cocos2d::plugin::ProtocolAds::getAdsListener()’ is deprecated (declared at jni/…/…/include/ProtocolAds.h:134) [-Wdeprecated-declarations]

Even though it was finally saying that publishing is successful.
That’s why I decided to downgrade my Android SDK build tools.
Let’s see what will be the result…

Well…
I’m sorry, I was unable to make the plugin work for me. It is probably something very small that I don’t understand.

I took this tutorial http://war1oc.tumblr.com/post/99479807498/admob-integration modified AppActivity.java and at least the Ad shows and works. Moreover, it enables me to use the latest google-play-services Admob version.

Later, I’ll give plugin-x another try.

I think you should refer to http://www.cocos2d-x.org/wiki/Plugin-X_Integration_Guide_for_Android, you can use the Eclipse to develop it in advance.

@samuele3hu I am trying to use plugin-x. Now I saw that there is this https://github.com/cocos2d-x/plugin-x/pull/99 pull request for plugin-x. It says that the admob-plugin is using old api which isn’t working anymore and the pr would update the plugin.

Does this really mean that all the work I did the last two days (and some other users) is for nothing because the admob plugin isn’t working? If that is really true I am extremely disappointed.

@samuele3hu I am getting this error

make.exe: Entering directory C:/Cocos/Development/SpaceSpyTest/frameworks/runtime-src/proj.android' make.exe: *** No rule to make targetjni/jni/…/…/…/cocos2d-x/plugin/luabindings/auto/lua_cocos2dx_pluginx_auto.cpp’, needed by `obj/local/armeabi/objs/cocos2dlua_shared/jni///__/cocos2d-x/plugin/luabindings/auto/lua_cocos2dx_pluginx_auto.o’. Stop.
make.exe: *** Waiting for unfinished jobs…

Could you give some advice? I think plugin-x lua integration is almost done but yeah…
Error is caused when I add

$(LOCAL_PATH)/…/…/…/cocos2d-x/plugin/luabindings/auto/lua_cocos2dx_pluginx_auto.cpp
$(LOCAL_PATH)/…/…/…/cocos2d-x/plugin/luabindings/manual/lua_pluginx_basic_conversions.cpp
$(LOCAL_PATH)/…/…/…/cocos2d-x/plugin/luabindings/manual/lua_pluginx_manual_callback.cpp
$(LOCAL_PATH)/…/…/…/cocos2d-x/plugin/luabindings/manual/lua_pluginx_manual_protocols.cpp \

and

$(LOCAL_PATH)/…/…/…/cocos2d-x/plugin/luabindings/auto
$(LOCAL_PATH)/…/…/…/cocos2d-x/plugin/luabindings/manual

to android.mk.