Quick Links: Download Gideros Studio | Gideros Documentation | Ultimate Guide | Gideros Development Center
New plugin available: Native mapping for Android & iOS - Gideros Forum

New plugin available: Native mapping for Android & iOS

PaulHPaulH Member
edited January 30 in Plugins
Folks,

It's taken long enough, but I've finally gotten around to finishing a native mapping pluging. This plugin makes it possible to overlay a Google Map or Apple Map over a Gideros app, and to add location markers to the map.

image

The plugin with installation instructions, plus plugin source code, documentation and a sample Gideros project are here: http://www.pishtech.com/gideros_map_plugin.zip

If anyone who works with the Gideros github repository is so inclined, feel free to add this wherever would be appropriate.

I built this plugin because I need it myself for an app I'm porting to Gideros. Hopefully it will be useful to others.

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

Comments

  • @PaulH This is great!

    How long did it take you to make this plug-in? Could you share your approach and experience?

    I'm very interested in building some simple asynchronous plugin-ins, but I don't know how to go about it. Which tools did you use to build the .so files?

    Many thanks
  • PaulHPaulH Member
    It took about a week to work out the plugin itself (not counting the Lua design or native coding.) I used NDK to build the .so files, but I wasn't successful integrating that step into Eclipse. I just called ndk-build from the command line. I wrote a batch job to do that, piping the error output to a file, then copy the resulting .so files to my test project in Eclipse, and finally open the error file in notepad.

    It took a few days of troubleshooting to build the example plugin from http://appcodingeasy.com/Gideros-Mobile/Creating-plugins-for-Android-in-Gideros. I wasted a lot of time troubleshooting strange errors that turned out to be due to stray non-ASCII white space characters that I picked up by copying the sample code from the web page rather than from the downloaded zip file. Apart from that, that guide is still pretty accurate for the simplest case. That creates a plugin with only static functions, though. If you want your plugin to create a class from which you can create objects in Lua, it gets more complicated.

    I tried months ago to build the plugin, but mapping out the functions called in IAB (the in-app billing) plugin was a tremendous headache. It's the kind of code where a function called do_it() calls a method called do_it() which calls a static function in another module called go_do_it() which calls a method called go_do_it() which... Etc. From the Lua call to the native Java function, it's 7 layers of code, and I only half understand why it's done that way. The IAB plugin might not have been the best example to work from, as its complicated further by defining an interface so many different frameworks can drop in to support different app stores. It's clever, but it's not the easiest code to follow. Eventually I had to set the project aside and get back to updates on other apps.

    At this point I have very little experience with Android Studio, and I don't know that the impact of switching from Eclipse to that will have on all of this. I appreciate that the goal is to export an APK without needing either Eclipse or AS, though I imagine that will add some steps to the task of creating a new plugin.

    Paul
    +1 -1 (+1 / -0 ) Share on Facebook
  • @PaulH

    Many thanks for the speedy reply. I really appreciate the information. I was really under the impression that Gideros was easy to extend, but now I'm not so confident.

    We need an expert to provide a guide that we can follow - a real world scenario, but not too complicated. Hopefully, we'll see some progress in this area this year.

    Our team is dedicated to Gideros. We'd really like to get to the next level of Gideros development as well as help maintain some of the plug-ins.

    Cheers

    Simon

    +1 -1 (+1 / -0 ) Share on Facebook
  • hgy29hgy29 Maintainer
    Nice work @PaulH,

    I'll push it to gideros repo if I get enough time to write an integration script for your plugin.

    BTW, it is true that some plugins have too much layers, but they are probably needed. I try to separate plugins code into a few layers myself:
    - A common Lua to C layer for all platforms
    - A C to JNI layer and a Java layer for Android
    - A C to ObjC layer for iOS
    +1 -1 (+1 / -0 ) Share on Facebook
  • antixantix Member
    Very awesome plug-in @PaulH!
    Check out my DevBlog, my GitHub, and my games Falling Animals | Breaky Wall | Exetor
  • talistalis Guru
    edited February 1
    @PaulH CongoRatz! Great plugin and a contribution.
  • piepie Member
    edited August 10
    This one should be featured, I knew it was there but it took me a while to find it again :)

    Unfortunately the android readme includes only Eclipse instructions: how would those change to use the plugin with Android Studio?
    Adding mapplugin to an Android project:

    Go to https://developers.google.com/maps/documentation/android-api/start#step_1_download_android_studio to install the Play Services SDK and get a Maps API key for your app.

    Export Android project from Gideros.
    Copy the src and libs folders into your exported Gideros Android project folder.

    Import Android project into Eclipse.

    Import existing android project into workspace:
    ...\android-sdk-windows\extras\google\google_play_services\libproject\google-play-services_lib

    Edit the project manifest in Eclipse and make the following changes:
    Change minSDK level to at least 11
    Add to end of Application:


    Add to permissions in manifest:


    In project properties, java build path, add
    android-sdk-windows\extras\android\support\v4\android-support-v4.jar
    android-sdk-windows\extras\google\google_play_services\libproject\google-play-services_lib\libs google-play-services.jar
    android-sdk-windows\add-ons\addon-google_apis-google-17\libs\maps.jar
    Under Order and Export, check the above 3 libraries for export.

    In src\com\giderosmobile\android\(your app)Activity.java:
    Add at end of imports: import android.support.v4.app.FragmentActivity;
    Change "extends Activity" to "extends Fragment Activity".
    is the short version from ar2rsawseen applicable?
    .jar files should go to app\libs
    .so files should go to respective app\src\main\jniLibs
    And all other .java files go to respective app\src\main\java
    Main activity is in app\src\main\java\com\giderosmobile\android
    And Android manifest is in app\src\main
    [edit: bonus question]
    Is it possible to open a position/marker in GoogleMaps app to get the route to it?

    Thank you, and thank you PaulH!
  • piepie Member
    edited August 26
    Hi, I am trying to build a gideros android player with native map support, but i am stuck trying to "translate" instructions to Android Studio:


    These are the steps I followed until now:

    .Get Maps API key for the app

    .Export project to Android Studio

    [[
    PROJECT is used to id the exported root folder.
    MAP_PLUGIN is used to id the folder where you placed the extracted zip file
    ]]

    .copy mapplugin folder from
    MAP_PLUGIN\AndroidPlugin\src\com\giderosmobile\android\plugins
    to
    PROJECT\app\src\main\java\com\giderosmobile\android

    .copy content of MAP_PLUGIN\AndroidPlugin\libs\
    to
    PROJECT\app\src\main\jniLibs

    .Edit Manifest in app\src\main as in readme file:

    Change minSDK level to at least 11

    Add to end of Application:



    .Add to permissions in manifest:



    .Edit Activity file located in app\src\main\java\com\giderosmobile\android as in

    readme file:
    Add at end of imports:
    import android.support.v4.app.FragmentActivity;
    Change "extends Activity" to "extends Fragment Activity".

    I am now stuck here:
    In project properties, java build path, add
    android-sdk-windows\extras\android\support\v4\android-support-v4.jar
    android-sdk-windows\extras\google\google_play_services\libproject\google-play-services_lib\libs google-play-services.jar
    android-sdk-windows\add-ons\addon-google_apis-google-17\libs\maps.jar
    How do I do this in Android Studio?
    I imported google play services as Library Dependecies in Project Structure, I don't know if that was enough though, because I get this error which seems to be unrelated:

    After pressing Run on device, it builds the app, then installs it, and then the app ForceCloses with this error on first run.

    java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.piretro.testmap/com.giderosmobile.android.testmapappActivity}: java.lang.ClassNotFoundException: Didn't find class "com.giderosmobile.android.testmapappActivity" on path: DexPathList[[zip file "/mnt/asec/com.piretro.testmap-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
    In my manifest there is also a notification by android studio
    (... excerpt from my manifest)
      <application android:icon="@drawable/icon"; android:label="@string/app_name"; android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:banner="@drawable/banner";>
    <activity android:label="@string/app_name"; android:name="com.giderosmobile.android.testmapappActivity" android:launchMode="singleTask" android:screenOrientation="portrait" android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
    <intent-filter>

    (...)

    Hovering with mouse pointer on com.giderosmobile.android.testmapappActivity says "Unresolved Package"


    Any help is appreciated... what did I do wrong?
    Thank you :)
Sign In or Register to comment.