appcelerator-titaniumappcelerator-alloyappcelerator-hyperloop

Create Titanium Appcelerator module from native android module


I am trying to create a Appcelerator module from a native android module located here. https://github.com/jaredrummler/ColorPicker Are there any tutorials online that will guide me in this process. This is my first attempt at this, so any kind of guidance will be very helpful. Is there anyway i can use a native module AS IS using Hyperloop?


Solution

  • Yeah this is possible. From that page it references the AAR file. AAR is similar to a JAR file, but with a few cavaets. So to do this you will probably want Titanium SDK v6.0+, and the higher version the better. Probably 6.2.2 is recommended, if not 6.3.

    So you will have to first enable Hyperloop for the project (google it), then place the AAR in a (probably newly created) folder: /app/platform/android/the-color-aar.aar. Then you'll have to know how to invoke the classes. That discussion and more you can find referencs to here: https://github.com/shouse/awesome-hyperloop-titanium/.

    From there you'll do a var colorpicker = require('com.jaredrummler.android.colorpicker') then figure out the proper syntax to invoke the classes in the AAR.

    Join us at http://tislack.org/ and find the Hyperloop channel to hit me up in real time, along with other devs who work with HL. Reference this url.

    I've also just started using https://github.com/google/android-classyshark to get more info from AARs, JARs, and APKs to be able to understand what the functions are on those libs. Here's a screenshot: https://imagebin.ca/v/3j1PZzSxP6SI

    Finally if it might make sense to use the 7.0.0 beta Titanium SDK so that you can do proper debugging via Chrome Inspector. If you build with appc ti build --platform android --debug-host localhost:9222 -l trace this will start a debugging session. After not long you'll see in the console something like:

    [WARN] JSDebugger: (main) [26,831] Debugger listening on ws://127.0.0.1:9222/a361771c-2273-4b1e-800f-0e8e9f0d74ec [WARN] JSDebugger: (main) [1,832] To connect Chrome DevTools, open Chrome to chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=127.0.0.1:9222/a361771c-2273-4b1e-800f-0e8e9f0d74ec [WARN] JSDebugger: (main) [0,832] Waiting for debugger to connect for next 60 seconds...

    Copy that URL into a newish version of Chrome and you'll be set to do a lot deeper introspection that will help your life outside of Hyperloop too.

    Cheers!