We rather enjoy a challenge, and every so often an exciting new challenge presents itself – this time in the form of building hybrid Android and iOS App for two of our recent clients; The NHS and Ford in the United States.
But what is a hybrid app I hear you ask..? Well they look and behave in pretty much the same way as any other apps you might find on your device – in layman’s terms, it makes a web application look and feel like a native application (in much the same way that PWA based sites aim to do).
So just how hard is it to build a hybrid app? Well, we caught up with one of the developers Alex Longshaw to talk about his experience and what he learnt during the process.
Can you quickly explain what your role is and what you do?
I’m a backend developer, mainly working in PHP within the Symfony2 framework. In my own time, I like to dabble with other languages and recently started developing Android apps using Java – something that I was able to bring through and use on these projects.
Describe three issues you encountered with the development of the Android app and how did you overcome them?
Initially, the first time I tested the app on a real device, I found that changing the orientation caused it to crash. This was a simple well-documented solution but it did ingrain the importance of thorough testing.
Web views don’t allow uploads by default, you have to build the functionality. We now allow uploads from your phone gallery, direct input from the camera and other apps which provide images such as Dropbox.
Supporting offline content was the most difficult task I faced when building the Android app. I initially tried using the built-in cache but it didn’t support the flexibility we needed. Instead, we manually cached pages allowing us to pre-fetch certain elements and customise how often different types of files are updated. It also meant that we had to synchronise cookies in order to download password protected content.
Were there any parameters or guidelines that caused you frustration?
Mostly, the guidelines were simple and didn’t really cause any issues. The main challenge was getting the native components to match the web components. This meant extracting the relevant CSS snippets and transforming them into the XML format that Android uses for layouts.
For high-resolution images such as logos, we use SVGs for our responsive websites, however, Android has limited support for these. There are a few libraries that help but the standard is to have 5 versions of the same file (hdpi to xxxhdpi).
How easy was the process of adding it to the Play Store?
Getting the app onto the Play store was a relatively painless experience. I already had a developer account so I just had to build a signed APK (the app file) and fill in content supplied by Rob and the visuals supplied by our Design Director, René.
Once we had it in the store in beta mode, all our staff with Android phones installed it and tested it out. I found out that transferring the app from my account to the company account requires it to be live so we had to ensure it was perfected before we could initiate the transfer.
What did you learn and how would you approach it differently next time?
Getting used to Java again was the first benefit. Android has great documentation and I have spent countless hours reading through the API. Coming from PHP development, I’ve not worked with multithreaded environments in a while so it will be useful for future NodeJS work.
When developing, I fell into the trap of reinventing the wheel and making the app unnecessarily complex. This caused me to underestimate the times it takes to build. I ended up refactoring my code to make use of some libraries such as Jsoup by adding the Maven repository to my Gradle dependencies.
In the future, I’d do some more research and get more involved in the community. Android development has a great ecosystem and lots of free and low-cost tools that I could have made use of. For example Genymotion, which is a faster and more feature rich emulator than is provided bundled with the IDE I used.
Can you name the tools you chose to build the app and why you chose to use them?
I did most of the development in Android Studio (with the odd change in terminal Vim). I chose to use Android Studio as it is the official IDE although I have used Eclipse previously. As with our web projects I used Git for version control and hosted the code on Bitbucket.
Although the virtual machines which come bundled with Android Studio were good, I had to test on physical devices to ensure the app was functioning correctly. I used a variety of phones including asking our Marketing and Insight manager to bring in his old, slightly smashed HTC Wildfire!
Probably the most useful tool is Crashlytics. Crashlytics sends me daily summaries of active and new users, crash reports and average session length. This includes a stack trace to quickly investigate any issues that might arise.