Archive for March, 2013

Correcting a Bug in the Latest Google NDK r8e

Friday, March 29th, 2013

In our continuing effort to inform you of ecosystem issues as we encounter them, the latest NDK toolchain update from Google contains a bug. This causes an issue when building the Titanium Mobile SDK from source. The fix is trivial, and is only necessary if you’ve updated to NDK version r8e, released March 21st, 2013 and are building Titanium Mobile using SCons.

To perform the fix, edit the file build/core/build-binary.mk under the Android NDK directory, replacing line 49:

$(cleantarget): PRIVATE_CLEAN_FILES := ($(my)OBJS)

With this:

$(cleantarget): PRIVATE_CLEAN_FILES := $($(my)OBJS)

The following output from “scons android” (when building titatitanium_mobile) is a symptom of the problem:
     [exec] rm -f src/native/../../generated/*
     [exec] rm -rf src/native/../../obj/*
     [exec] Clean: kroll-v8 [armeabi]
     [exec] rm -rf (TARGET_OBJS)
     [exec] /bin/sh: -c: line 0: syntax error near unexpected token `(‘
     [exec] /bin/sh: -c: line 0: `rm -rf (TARGET_OBJS)’
     [exec] make: *** [clean-kroll-v8-armeabi] Error 2

 

More information can be found here:

https://groups.google.com/forum/?fromgroups=#!topic/android-ndk/3wIbb-h3nDU

There is a second issue that only affects Max OS X developers using the 64-bit NDK (i.e. the download with the file name android-ndk-r8e-darwin-x86_64.tar.bz2). The fix is trivial and requires you to make the following one-line changes to these two files:

${ANDROID_NDK}/ndk-build: Replace line 158:

file -L “$SHELL” | grep -q “x86[_-]64″

with this:

file -L “$SHELL” | grep -q “[xX]86[_-]64″

${ANDROID_NDK}/build/core/init.mk: Replace line 229:

ifneq (,$(shell file -L $(SHELL) | grep ‘x86[_-]64′))

with this:

ifneq (,$(shell file -L $(SHELL) | grep ‘[xX]86[_-]64′))

As a note, you should be using the 64-bit NDK if your system supports it, since you will get 30% faster builds. The 64-bit tools utilize host resources better (faster, handle larger programs, etc) and they should function identically to their 32-bit counterparts, i.e. 64-bit toolchains still generate 32-bit binaries for Android.

This issue will be fixed by Google in the next release of the NDK. We will update this post with any new information we receive.

Appcelerator Titanium: Patterns & Best Practices (Book)

Thursday, March 28th, 2013

The following guest spot is courtesy of Trevor Ward (@thewarpedcoder) and Boydlee Pollentine (@boydleep), the authors of the new “Appcelerator Titanium: Patterns & Best Practices” book. Trevor and Boydlee are both active Titanium community members and Titans contributing across a wide-range of activities, including organizing Titanium conferences, speaking at mobile  conferences, hosting Titanium trainings and helping out on the Q&A to name a few.


It is nice to be asked by Appcelerator to contribute to their blog. Especially when you get the chance to promote a new book.

Over the last few months Boydlee Pollentine and myself (Trevor Ward) have been working on providing a resource we hope will help people using Titanium. On the 23rd February Appcelerator Titanium : Patterns and Best Practices was released via packt publishing.

The book starts by covering some best practices for JavaScript and Titanium, before showing how to implement commonJS and cross platform design methods. The final chapter explains how to implement a non SQL solution using jsonDB.
While writing this post I thought I would see if anybody had reviewed the book, and Jason Kneen said this:

“This book is essential reading for anyone developing with Titanium. If you’re new to Titanium, this book will give you a firm foundation on which to build your apps to ensure code is clearly written, well-structured and application resources are well managed. Even if you consider yourself an experienced developer there are still tips in this book that will improve your code and the performance of your applications. Some great advice on reusability of code and cross-platform development too.”

We hope you like it and it provides a useful benefit to your coding.

The book can be purchased through any Amazon store or directly from the publishers.

Titanium Mobile Tizen now available

Tuesday, March 26th, 2013

Hot on the heels of our preview release several weeks ago, we’re pleased to announce GA support for the new Tizen platform in the Titanium SDK. Tizen is a robust and flexible operating system, based on Linux and HTML 5. Available devices include smartphones, tablets, netbooks, in-vehicle dashboards and smart TVs.

The general availability of Tizen support is included as part of our 3.1.0 release. However, we are promoting it in advance in order to encourage you to begin developing applications for the platform in anticipation of the May opening of the Tizen app store. As such, we’ve tested a particular build of 3.1.0 for Tizen support, and we are linking to that directly from the platform page below. To get started, read more here. There are some important items to watch as part of the release notes in regards to the Tizen tooling on OS X, so please review the aforementioned linked page carefully.

Feedback and contributions are appreciated. You can check out the repository at https://github.com/appcelerator/titanium_mobile_tizen. We welcome your contributions and support of this new addition.

Titanium appCamp London 2013 in Review

Tuesday, March 26th, 2013

The following guest post is from Ketan Majmudar, an active Titanium developer and organizer. He recently helped organize Titanium appCamp, a mashup of a traditional barcamp and hackathon. The details of the event are in this post.

Ketan and other Titanium organizers have been instrumental in hosting several recent community-led Titanium events (see also ticonftitokyo). There’s a strong interest for more of these events where developers can share and learn from the amazing projects that others in the community are working on. If you are interested in organizing an event, contact community@appcelerator.com for more information about support and guidance from Appcelerator.


The World’s first Titanium AppCamp Unconference/Hackathon kicked off in London, England last month!

Titanium AppCamp Logo

February 2-3rd 2013 marked the launch of London Titanium’s flagship event. It was designed to be a mashup of your traditional barcamp style event and a typical hackathon. I’ve been wanting to run an event like this for a long while.

Last month, we had over 100 people attend the event which was held at the amazing Mozilla Space in central London. With its rock-solid wireless internet, comfortable working space and cool refreshment area, Mozilla Space is an ideal location for hosting such an event. We welcomed attendees from all over Europe, including different parts of the UK, Denmark, Sweden, Italy, Hungary, Cyprus as well as the US. We even had interest from as far away as India!

2013-02-02 10.14.13

I envisioned an event where both experienced devs and complete newbies were able to learn; share ideas, tips and tricks with each other; and attempt to get to grips with real-world hacks without feeling intimidated. I’ve attended a few hackathons and barcamps over the years, and have also run Titanium sessions at them, so I wanted a run a mobile/Titanium-focused event. London Titanium seemed the perfect vehicle for that!

An organisation team was assembled. I was knocked out by the approach everyone took and the energy given to make this happen! The team (in black t-shirts on the day) worked tirelessly behind the scenes for months beforehand to make the event happen — designing t-shirts, organizing breakfast, lunch & dinner, catering to all diets, and making sure kick-ass coffee was available all weekend! All of this had to be at no charge to the attendees, and on the day, we relied on a bigger team of Titans & volunteers to help us pull it off.

We had a larger number of newcomers to mobile development than expected at the event. This just proves the power of the unconference. We quickly mobilised the attending Titans (in special green expert t-shirts so you couldn’t miss them!) and ran 2 large Titanium bootcamps, helping Mac and Windows newbies install all dependencies and Titanium Studio on everyone’s machines. Thanks must go out to all the Titans — it is not surprising that the feedback was that they did an excellent job!

The volunteers (in special blue t-shirts) helped us all day, and late into the nights, making sure there were great talks — and plenty of coffee and food. Thanks go out to them all for giving up their own weekends to make everyone’s experience awesome.

Two of the biggest interests during the weekend came in the form of the new Alloy framework and Blackberry support for Titanium. Appcelerator was kind enough to send Tony Lukasavage, the project lead on the Alloy Project to speak and support the event. He joined us and selflessly shared his knowledge and remained approachable all weekend. His attendance was so popular! Attendees were scrambling to see Tony’s talk on Saturday afternoon. Blackberry Native BB10 devs and Titan Jeff Antram were around all weekend to help developers install and configure their Titanium Environments for BB10 development. Generously, Blackberry provided us with 5 Playbooks as prizes for the hackathon.

Dinner came in the form of burritos from local outlet Chipotle. They went down a treat, but were so filling. One of the hardest things to judge are catering numbers, and I was determined not to throw anything away. Attendees scoured the web, tweets were sent out, and eventually, in an attempt to find a way of not throwing away perfectly good hot cooked food (we had missed the pickup deadline for a local food charity that operated in Central London), myself and 4 volunteers walked out onto the streets of London at 11pm and distributed burritos to the homeless community. Nothing went to waste.

Day 2 kicked off early with bagel breakfasts for everyone and the day was quieter, yet more focused. We welcomed the hack entries and were suprised at the number of ‘Game themed’ hacks. This fit in nicely with the prizes from our Startup Sponsor, Lanica, who generously provided 5 prizes to hack winners, in the form of early-access beta to the Platino engine, as well as codes to use their Animo spritesheet tool.

The hack entries were a lot of fun and as usual, had their mix of humour, polish and frustration! Some of the entries included:

Eng Wei Chua who built a “BB Bieber app” using the Appcelerator BB10 pre-release. His intention was to build an app that connected to an image gallery API, such as Flickr. Eng has been developing an app for the past 12 months which utilizes a single code base, but outputs to iPhone, iPad, Android phone and tablet.

Gergely Cziva built a demo called “Space Game”. He used Alloy and the Websocket module for the iPhone app, and HTML5 canvas + websocket + node.js server for the game. Gergely has been using Titanium since version 1.5 and has developed a series of apps on the platform.

We would like to once again congratulate our hackathon winning apps (in no particular order): BieberView, SpaceGame, One pound fish, Get It Sorted, Best Effort, Stalagtweets, SnapADish and Who stole my beer? Our sponsors generosity means they won one of five BlackBerry Playbooks, five Lanica Software Packs for game development, or an Amazon or iTunes Gift Vouchers – not bad while having fun writing code and being fed quality food from local restaurants!

Watch the hackathon demo’s here (courtesy of Kosso):

Video streaming by Ustream

Pics: We have a set of images on Flickr: http://flic.kr/s/aHsjDRnK6A Plus, the event has been preserved at eventifier – http://eventifier.co/event/tiappcamp13/

A couple of weeks following on from our event saw another User Driven conference kick off in Valencia, Spain, tiConf EU! Boydlee Polentine (the main ticonf organiser) helped us out during the Saturday at our event as one of our resident Experts.

Finally, we would like to thank our sponsors: Appcelerator, Mozilla, BlackBerry, Lanica and Multizone. Community-driven events would be impossible without them! Please follow us and them on twitter, and thank them if you can.

All in all, AppCamp was a great success! We learned a lot from the event and will most definitely be running another one in the future. Watch this space.

Organisers - @ketan, @mfujica, @nuxnix and @thiswayup

Sponsors - @appcelerator, @mozldn, @blackberrydev, @lanicaco, @multizone

More about Ketan:
Ketan Majmudar is a Titan and TCAD certified. He has been involved with the organisation and running of the London Titanium Meetup group since its inception in May 2011 (the group was co-founded by Liz Myers & Betty Tran). Ketan has been helping to organise the meetups since the group’s launch. and has been running the group with co-organiser, Joe Lee since May 2012. Ketan has published and worked on a few cross platform Titanium Apps, including the SCI-FI-LONDON Surrey & Tayside Police and the CuppaCoffee app (for Blackberry 10).

London Titanium has 320 members of the meetup group, and we are growing each month. Please consider joining our group if you want to be kept informed of new meetups talks and events –http://www.meetup.com/London-Titanium

 

 

Consuming Web Services

Monday, March 25th, 2013

In a previous post I talked about a library that makes it super easy to communicate with web services. In this post, I’ll step back a little bit, explain what exactly a web service is, and go through the process of consuming data from them.

Understanding web services

By its name, a Web service can be any service that is accessed through a web browser, such as Dropbox, Evernote or Gmail. However in software terms, a web service is a program that you can interact with through a network call. In modern web applications, developers have implemented groups of web services called APIs (Application Programming Interface). The concept of an API is not new and it’s not exclusive to web or mobile programming, but I’ll only talk about its application to web and mobile technology.

Ten years ago the idea of having data available for consumption by third-parties was not common, in fact it was avoided at all costs. Companies adopted the approach of “my data is my data, and it’s my competitive advantage”. Today, we have seen that providing access to data is an essential part of companies like Facebook and Twitter. For them, having an API is a way of expanding the reach of their services, increasing engagement, innovation and adoption. Even governments have embraced the use of APIs in order to speed up the development of web and mobile apps for their citizens.

JSON

JSON, or Javascript Object Notation is the data structure of preference for today’s web services. As opposed to its counterpart XML, JSON provides a much leaner way of structuring data, ideal for data transfer over mobile networks.

The beauty of a web service is that it provides an agnostic way of transferring data over the Internet that is both platform-independent and language-independent. Every computer language has a string data-type. With JSON you transfer an object in string format and the receiver converts it back to a native data structure. That’s why you can have a web service written in Python and consume it from Javascript, or one written in PHP and consume it from VB.NET. There’s a JSON implementation for virtually all modern programming languages, but its home base is Javascript.

Why is JSON so important

The combination of Javascript objects and arrays make JSON strings multi-dimensional. The JSON string can either start as an object or as an array depending on the design of the web service, but nesting them is what makes this format so versatile. However, at the same time, as JSON files get more complex, they become difficult to read. This is normal, so don’t feel overwhelmed. In fact, you’re not supposed to be able to read it; JSON was designed to be consumed by computers. I’ll explain more technical details about Javascript object and arrays in a future post.

HTTP GET and POST

The two most important methods for HTTP communications are GET and POST, GET being the default. You perform a GET every time you call a URL. Although you can send data through a GET call, it’s usually data that will be used as contextual information to retrieve more data. You perform a POST every time you send data to a web service, such as filling out a form. The POST method encodes the data in a different way, providing more security and allowing you to send more data in each request.

Consuming data

If you’re going to be working with JSON, you will need some tools to help you along the way. In my opinion, the most important of these is the JSONView extension for your browser. This extension will allow you to view JSON files not as a block of unreadable text, but as a hierarchical structure. Although this extension was originally developed for Firefox, there is a port for Google Chrome that adds a the feature of automatically displaying your Javascript array/object path. Head over to http://jsonview.com and install the extension on your browser. Browse to your JSON endpoint (URL) and see what happens. In this example I’m browsing to https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=appcelerator&count=20.

You’ll see the JSON string neatly formatted. Also, notice that you can collapse and expand each branch. Last but not least, hover over any of the entries and see how it displays on the status bar the path to use on your Javascript code. In this example [0].text refers to the “text” property on the item “0″ of your array.

With the XHR library described earlier, you perform a HTTP GET call with a single line.

xhr.get(url, onSuccessCallback, onErrorCallback, options);

The callbacks are simply functions you send to the library to be used later on, in this case when the process was successful or when there was an error. Note that you need to define these functions before calling the GET or POST method.

Let’s examine the onSuccessCallback.

When you receive the data in the variable e, we run the JSON.parse method on the data property. This will create a native Javascript object in the variable response. Since we had previously examined the response using JSONView, we know it is an array, so can then loop through all the items. Inside each array element, there’s a complex object. Using dot notation we extract each of the properties from the object. Run this code and you’ll get tweets in individual variables, ready to be used as needed.

To perform a HTTP POST, you simply add an additional parameter to the POST method. Testing POST is a little bit different though, because sometimes there’s really not feedback from the server. Time for another cool tool that might help you. To test HTTP POST calls before actually hooking into my actual web service, I use http://www.posttestserver.com/ as my endpoint. This website is just sitting there waiting for HTTP POST calls, naturally for testing purposes. The POST data is sent to the XHR library as a regular Javascript object. The values you’re assigning to the payload variable are equivalent to the values on an HTML form, so if you’re interacting with PHP code to submit a form, this variable holds the values of each form field.

The POST server website will confirm that it indeed received the data and will give you a URL to view the data received. Remember, this is a public website so only use it to send test data.

Once you know that your data is being properly received by the “post server”, then you know that your app is working properly, so not switch the post call to the actual one and you’re set.

Now that you can communicate with web services, the next step is to do something useful with the data. By combining Appcelerator Alloy with this very basic example, you can have a native interface to read tweets. You can see all the required files here: https://gist.github.com/ricardoalcocer/5190529. Here’s what it looks like.

Want some homework? Why don’t you implement the “Post a tweet” functionality?

In a final post of this series, I’ll explain how to create your own web services using Appcelerator Cloud Services. Stay tuned.