I just lost a week of my life dealing with one bug in a Cordova/Ionic mobile app

(written by lawrence krubner, however indented passages are often quotes). You can contact lawrence at: lawrence@krubner.com, or follow me on Twitter.

Over the last week I had two marathon days where I worked more than 12 hours, and I had 4 normal days where I worked 6 to 8 hours, and all of it was wasted on one bug.

I’ve a friend who wanted an app built that would work for both iOS and Android. He contracted with a team in India to build it. They used Cordova and Ionic.

When they were done with the project they sent it to him. He got some user feedback and decided some minor changes were needed. I agreed to help him.

I’ve been spoiled by communities such as Ruby and Clojure, both of which have fantastic build tools.

Clojure has Leiningen. It’s amazing. I’ve never had any problems building anything in Clojure.

Ruby is almost as good. Ruby has “bundler” which takes care of 99% of the build problems on a Ruby project. The only times I run into problems is with stuff like Nokogiri, where Ruby depends on outside libraries to help build the software. The problems with Nokogiri are legend. I’ve also run into problems trying to install imagemagick or rmagick.

But the worst problem I ever faced in Ruby was child’s play compared to Cordova and Ionic. This is a world where all the code is 3rd party code. There is no one package manager that manages everything. Version conflicts are abundant.

Here are all the places where working code from one developer might fail to work for another developer:

different version of Node

different version of npm

different version of cordova

different version of any plugin

different version of package.json.lock is out of sync with package.json

different version of Xcode

different version of Mac OSX

if on Windows, presumably problems with Eclipse and Android.

These cross platform mobile app development kits are fairly new, and they are immature, and they are targeting two huge code bases (Androd, iOS) that keep changing, so the whole system is much more fragile than anything else that I’ve worked with in many years. It reminds me of trying to work with Linux back in 1997, before there was much device support for Linux.

Keep this warning in mind: you can lose weeks and get nothing done.

Anyway, I wanted to run this command:

ionic build

but I kept getting:

[18:33:21]  typescript: src/providers/services/pushnotification.service.ts, line: 54 
            Type '{ android: { forceShow: false; sound: true; }; ios: { alert: "true"; badge: false; sound: "true";...' 
            is not assignable to type 'PushOptions'. Types of property 'android' are incompatible. Type '{ forceShow: 
            false; sound: true; }' is not assignable to type 'AndroidPushOptions'. Property 'senderID' is missing in 
            type '{ forceShow: false; sound: true; }'. 

      L53:  initPushNotification(login_token) {
      L54:    const options: PushOptions = {
      L55:      android: {

Error: Failed to transpile program
    at BuildError.Error (native)
    at new BuildError (/Users/lkrubner/projects/chet/full_clone_of_pg_code/peero_mobile/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)

I finally found a solution here:


change your options to a any object instead of a PushOptions like the follow snippet:

const options: any = {

It’s a terrible hack, but it works.

And yet, this code did run for the original developer. Why is that? Clearly, they were working with a different version of _____________ and that allowed it to work. But unless I could exactly setup my machine to imitate his machine in every way, I was facing this error.

This is a fragile eco-system.

Post external references

  1. 1
  2. 2
  3. 3