Building a mobile app with PhoneGap: the good, the bad and the ugly

11/26/2015 05:00:00 PM

Over the years a lot of mobile operating systems have emerged and have battled each other for dominance in an ever changing environment. This competition has quite a lot of advantages for consumers: a lot of innovative features are added to make people choose one Operating System over the other. 
Since the market share is split, and a lot of different Operating systems are used, apps need to be developed as well. And for companies deciding which OS to develop for is always a big decision on both time and budget.

Off course this problem wasn't a big secret, since I was a Windows Phone user for quite a while. Windows Phone users usually weren't selected by the big companies to develop apps for, simply because the market share was / is too small to spend big budgets on.
Android and IOS are the market leaders right now and companies decide to only develop for those platforms for the best ROI. That is off course a solid choice, but that leaves out other Operating Systems like Windows Phone and Blackberry.

So why not develop one app that could run on all devices? Why wasn't this possible, it would make things so much easier! This was the question I asked myself and caused me to take a look around.
That is when I discovered Cordova / Adobe PhoneGap. It allows developers to use HTML/CSS and Javascript to develop mobile apps that will run on virtually any device you set your mind too. Write one app, deploy to many.

The dream

The dream of PhoneGap is to allow developers to write one app that will run on virtually any device as a seemingly native app. It is basically writing a mobile website and making it run as an app on any android, IOS, Windows Phone, ... device without having any knowledge of the OS programming language itself. If it works on one device, it works on all devices!

...and reality

But that is still a dream. Once you need to access native elements of the OS like the camera, adding sounds or using NFC it becomes a lot more difficult to do: you need to start using plugins which are created by the community as open source projects.

Not that I do not like Open Source, I like it a lot. But if a developer gets tired of the project, it just doesn't get updated and bugs will remain ... causing crashes and memory leaks.

Plugins also require people to write native code for each Operating system and link it to the Javascript system that Cordova/PhoneGap uses. So even though you don't need to know how the OS works, they do. And if they don't it is quite possible the code just isn't up to par and will cause issues over time.

Device/OS specific issues

When developing my app I ran into issues that only happened on specific versions of Android. Simple things like a font showing on one version, and not on the other. Audio playing on IOS, but not on Android.
And at that point you need to start writing OS and device specific code, which really defeats the purpose. Sure it will be in Javascript, but that makes certain issues a lot harder to track down and fix.

One of the issues I ran into was a memory leak, after an hour or so the entire OS started to slow down and the memory was acting up. Off course you immediately know that you have a memory leak, but where is it coming from? Memory leaks are quite impossible to track in Javascript and HTML, especially if it takes so long to emerge. 
If you use a lot of PhoneGap plugins, you need to check the code of each one if they are causing it.

In my case it was the Media plugin to play sounds, it would load in my MP3 sound every time it was played and put it in memory. It simply wasn't removed causing the memory to slowly fill up.
But figuring this out took me a few hours which I could have spent on other things if I could easily monitor memory usage like I could in Java.

But in the end I figured it out and the app worked like it should again.


PhoneGap is a great tool if you are writing an app that does not make any use of native functions of devices. If the app should just be like a website, PhoneGap is the tool for you. But if you want a lot of native functionality like NFC, camera access, contacts, ... you will need a lot of testing devices to see if it works like it should.

You Might Also Like

0 reacties