Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
Creating a Gideros plugin using Android Studio - Gideros Forum

Creating a Gideros plugin using Android Studio

simwhisimwhi Member
edited February 2017 in Plugins
Hi everyone,

Over the last few days I have been trying to build the example plugin project as outlined on: http://appcodingeasy.com/Gideros-Mobile/Creating-plugins-for-Android-in-Gideros

Of course that guide refers to Eclipse which is no longer supported by Google, as well as being dropped by the Gideros project.

So, I have done a lot of research and resolved a lot of build issues, but I still can't seem to get it working in AS. When I rebuild the project the .so are not built, but there are no build errors. It could be something to do with the Android.mk file or the build system itself. I'm a bit stuck now.

I'm using the latest NDK and the gradle experiemental build v0.9.0-beta4.

Here's the AS project and Gideros project in drop box

https://dl.dropboxusercontent.com/u/40935009/plug-in-example.zip

I'm nearly there. I just need a little help/advise from either a Gideros maintainer or a forum user that has already built a plugin.

Many thanks in advance,

Simon

Likes: SinisterSoft

+1 -1 (+1 / -0 ) Share on Facebook

Comments

  • Hi, Is there anyone here that can help me with this?
  • antixantix Member
    edited February 2017
    I personally feel this would be a good thing to get updated. All these outdated documents are a constant source of frustration to everyone.

    Maybe if the tutorial can not be updated currently, then the obsolete one at least could be removed?

    @simwhi, sorry I can't be of any actual help here :(

    @hgy29, didn't you share some french document recently that was about writing plugins? If you could post it again I'd have a go at converting it since my current project is nearly finished.
    Follow me on FaceBook Check out my DevBlog, my GitHub, and try my games...
    Falling Animals | Breaky Wall | Exetor | Mini Putt Golfing | Ninja Fruit Master
  • @simwhi, arghh it's rather involved :D
    Follow me on FaceBook Check out my DevBlog, my GitHub, and try my games...
    Falling Animals | Breaky Wall | Exetor | Mini Putt Golfing | Ninja Fruit Master
  • simwhisimwhi Member
    edited February 2017
    Hi all,

    Is there no none on this forum that can assist with this? I think I am close!!!

    I, as well as other forum members have been asking for help on this important topic for a long time now. I would like to make some plug-ins as well as contribute, but I do not have the prequisite knowledge to build the projects in Android Studio. The complete build process is overly complicated.

    According the the main spiel on the Gideros website;

    "You can easily extend the core with plug-ins. Import your existing (C, C++, Java or Obj-C) code, bind to Lua and interpret them directly."

    Maybe this should be reworded to: "It is possible to extend the core..." as this is a more precise.

    I have found that this is not just an issue with Gideros, but also affects a lot of other game frameworks. The developers seem to gloss over the extensions / plug-ins in favour of game features instead. My research into other frameworks have shown that they either a) have no extensions / plug-ins system or b) have extensions / plug-ins but the documentation is outdated / sparse.

    There are some exceptions of course to the above such as Corona, but their plug-in development have restrictions attached (you cannot write an ad provider plug-in).

    If you are a hobbyist game developer I suppose this is less of a problem. However, if you are trying to grow a business then extensions start to become more of a main focus. We could of course pay someone to help us create our plug-ins, but in that case we would not be willing to share, or we would share at a cost. I personally would like to share with the community.

    In order to grow this community we need to have either an easy Gideros plug-in architecture or real world tutorials.

    To summarise what I have done already (based on Eclipse / Gideros plug-in):

    1. I have created a basic Gideros project.
    2. I Exported to Android Studio project.
    3. I added Gideros specific header files etc
    4 I added specific java code.
    5. I added the blinding C/ C ++ code.
    6. I Added Android.mk / Application.mk files.
    7. I Configured gradle files to build using Android.mk file.
    8. The project builds with errors but no . so files are created.

    The above is the extent of my knowledge / experience so far.

    Cheers,

    Simon

    Likes: keszegh, Holonist

    +1 -1 (+2 / -0 ) Share on Facebook
  • i also think that the fact that
    "You can easily extend the core with plug-ins. Import your existing (C, C++, Java or Obj-C) code, bind to Lua and interpret them directly."
    was always a distinguishing feature of gideros, right from the beginning. so it should be doable, if not easily but at least by someone motivated, which @simwhi definitely seems so.

    Likes: antix

    +1 -1 (+1 / -0 ) Share on Facebook
  • simwhisimwhi Member
    edited February 2017
    @keszegh Thanks for the comment and support. Surely, there must be a better way to this.

    Likes: antix

    +1 -1 (+1 / -0 ) Share on Facebook
  • hgy29hgy29 Maintainer
    @simwhi, don't you use ndk-build to build the .so files ? This how gideros build script does it.

  • simwhisimwhi Member
    edited February 2017
    @hgy29

    The gradle build system in Android Studio is configured to use ndk-build.cmd, but it doesn't seem to do anything (well, I haven't seen anything). I have followed multiple tutorials on this, but to no avail. I think one of the problems is that the build system is always changing. I used the experimental build tools as suggested on an Android development site.

    Another way to make the .so files would be to use CMake, but I decided against that because I want to stay as close to the old Eclipse tutorial as possible.

    Do you think there are any ways to improve / ease plug-in integration?

    Regards,

    Simon
  • hgy29hgy29 Maintainer
    I never used the NDK integrated with AS, so I can't say how to build plugins with this.
    When building gideros plugins for a release, the build scripts just invoke ndk-build command from within the android side of the plugin source tree, and nothing more: the .so files are build.

    Can you try this from a command line prompt ?
    Navigate to the folder containing the subfolders jni, libs, src, objs, etc, then just invoke 'ndk-build.cmd' from there.

    Note that we use NDK R10, we had trouble using more recent versions of the NDK.
  • @hgy29 Thanks for the info. I'll take a look at reverting to NDK R10 first and then go from there.

    Many thanks.
  • @simwhi, sorry I've been really slack doing renovations on our house. I'll get onto that document this evening :)
    Follow me on FaceBook Check out my DevBlog, my GitHub, and try my games...
    Falling Animals | Breaky Wall | Exetor | Mini Putt Golfing | Ninja Fruit Master
  • @antix No problem. It's more the Android Studio side of things that I need help with at the moment. But many thanks anyway.
  • simwhisimwhi Member
    edited March 2017
    Hi all,

    Sorry for the delay in posting my progress. I've been ultra busy with app updates etc. Anyway, after having a Skype chat with @hgy29 (really appreciate it), I have managed to make some progress. I got the following output from running the ndk-build.cmd from the Android Studio jni folder:
    <img class="emoji" src="/forum/resources/emoji/anguished.png" title="D:" alt="D:" height="20" />\plug-in-example\android-studio-project\ExamplePlugin\app\jni>ndk-build.cmd
    [armeabi] Prebuilt       : liblua.so <= jni/../jniLibs/armeabi/
    [armeabi] Prebuilt       : libgideros.so <= jni/../jniLibs/armeabi/
    [armeabi] Install        : libexampleplugin.so => libs/armeabi/libexampleplugin.so
    [armeabi] Install        : libgideros.so => libs/armeabi/libgideros.so
    [armeabi] Install        : liblua.so => libs/armeabi/liblua.so
    [armeabi-v7a] Prebuilt       : liblua.so <= jni/../jniLibs/armeabi-v7a/
    [armeabi-v7a] Prebuilt       : libgideros.so <= jni/../jniLibs/armeabi-v7a/
    [armeabi-v7a] Install        : libexampleplugin.so => libs/armeabi-v7a/libexampleplugin.so
    [armeabi-v7a] Install        : libgideros.so => libs/armeabi-v7a/libgideros.so
    [armeabi-v7a] Install        : liblua.so => libs/armeabi-v7a/liblua.so
    [x86] Prebuilt       : liblua.so <= jni/../jniLibs/x86/
    [x86] Prebuilt       : libgideros.so <= jni/../jniLibs/x86/
    [x86] Install        : libexampleplugin.so => libs/x86/libexampleplugin.so
    [x86] Install        : libgideros.so => libs/x86/libgideros.so
    [x86] Install        : liblua.so => libs/x86/liblua.so
    The next issue is that the .so files are located in the libs folder. When I run the Android Studio project I get this error in the log:
    E/AndroidRuntime: FATAL EXCEPTION: main
                      Process: com.exanple.exampleplugin, PID: 23117
                      java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/com.exanple.exampleplugin-2/base.apk"],nativeLibraryDirectories=[/data/app/com.exanple.exampleplugin-2/lib/arm, /vendor/lib, /system/lib]]] couldn't find "libexampleplugin.so"
                          at java.lang.Runtime.loadLibrary(Runtime.java:378)
                          at java.lang.System.loadLibrary(System.java:998)
                          at com.giderosmobile.android.ExamplePluginActivity.(ExamplePluginActivity.java:45)
                          at java.lang.reflect.Constructor.newInstance(Native Method)
                          at java.lang.Class.newInstance(Class.java:1572)
                          at android.app.Instrumentation.newActivity(Instrumentation.java:1068)
                          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2303)
                          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2466)
                          at android.app.ActivityThread.access$1200(ActivityThread.java:152)
                          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1341)
                          at android.os.Handler.dispatchMessage(Handler.java:102)
                          at android.os.Looper.loop(Looper.java:135)
                          at android.app.ActivityThread.main(ActivityThread.java:5538)
                          at java.lang.reflect.Method.invoke(Native Method)
                          at java.lang.reflect.Method.invoke(Method.java:372)
                          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
                          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
    From the above output I can see that it's looking for libexampleplugin.so in "lib" (no "s") folder. However, the .so files were created in the "libs" folder. How can I change this so that I can copy the created files into their respective jnilibs/arm, ... etc folders?

    I hope you guys understand.

    Cheers

    Simon

    EDIT- Here are the .mk files.

    Application.mk:
    APP_STL := gnustl_static
    APP_CPPFLAGS += -fexceptions -frtti
    APP_PLATFORM := android-8
    APP_ABI := armeabi armeabi-v7a x86
    APP_OPTIM := release
    Android.mk:
    # Set the current path - my-dir returns the path where Android.mk is located
    LOCAL_PATH := $(call my-dir)
     
    LOCAL_PATH := $(call my-dir)
     
    ###
     
    include $(CLEAR_VARS)
     
    LOCAL_MODULE            := lua
    LOCAL_SRC_FILES         := ../jniLibs/$(TARGET_ARCH_ABI)/liblua.so
     
    include $(PREBUILT_SHARED_LIBRARY)
     
    ###
     
    include $(CLEAR_VARS)
     
    LOCAL_MODULE            := gideros
    LOCAL_SRC_FILES         := ../jniLibs/$(TARGET_ARCH_ABI)/libgideros.so
     
    include $(PREBUILT_SHARED_LIBRARY)
     
    ###
     
    include $(CLEAR_VARS)
     
    LOCAL_MODULE           := exampleplugin
    LOCAL_ARM_MODE         := arm
    LOCAL_CFLAGS           := -O2
    LOCAL_SRC_FILES        := exampleplugin.cpp
    LOCAL_LDLIBS           := -ldl -llog
    LOCAL_SHARED_LIBRARIES := lua gideros
     
    include $(BUILD_SHARED_LIBRARY)
  • HI all,

    Finally got there!!! I just need to write a tutorial with a real world example that the community can add to over time. Special thanks to @hgy29.

    Cheers,

    Simon

    Likes: keszegh, antix, hgy29, pie

    +1 -1 (+4 / -0 ) Share on Facebook
  • Hi all,

    So, I've got the simple plug-in working, but I'm still scratching my head on how to get asynchronous calls to work. I've taken a look at the various plug-ins that are part of the Gideros installation, but to be honest I'm lost on how they work. I don't have the prerequisite knowledge in this specific area.

    Basically, I want to create a plug-in that uses the Android text-to-speech (TTS) features. I think this would:

    a) provide a simple demonstration of a real world situation using asynchronous and non
    asynchronous calls between Lua <---> C/C++ <-----> java
    b) be fairly easy to follow (I managed to write an Android app in about 10 minutes)
    c) The plug-in could be useful to community members.
    d) Additional features could be added in the future

    Could someone give me some pointers / guidance on where to start?

    Cheers

    Simon
  • Hi there,

    Just bumping this again to see if anyone can help me with asynchronous callbacks.

    Alternatively, we would be willing to pay for someone to develop and document a small plug-in project for our games. The project would be to implement Text To Speech (TTS) plug-in for Android.

    If you are interested, please send me a private message so that we can discuss the details further.

    Thanks
Sign In or Register to comment.