Add Cordova plugin in package.json only if ionic Cordova build is android

Recently we used External Cordova plugin that works only for android platform. It is not working for iOS platform and we are facing build fails for the iOS because of the plugin.

Is it possible to add the plugin only for the android platform.

I’ve found that the only clean way to make it work is to modify 3 things:

  1. Edit the plugins/PLATFORM.js file (ex. plugins/android.js) and remove the plugin object from the “installed_plugins” array

  2. Do the same for the platforms/PLATFORM/www/cordova_plugins.js file where PLATFORM could be ios, blackberry10, firefoxos etc. In the android case will be inside assets/www instead of just www

  3. Last step is to delete the plugin directory inside platforms/PLATFORM/www/plugins/ . In your case again it will be assets/www and not just www