Can't add platform Android when building Ionic 3 app - Sqlite Issue?

I’m trying to build an Ionic 3 app I haven’t built for a while and getting an error when I try to add the Android platform to the app…

ionic info

Ionic:

   Ionic CLI          : 5.0.1 (C:\Users\User\AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.4

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 2.1.4, (and 9 other plugins)

Utility:

   cordova-res : 0.3.0
   native-run  : 0.2.5

System:

   Android SDK Tools : 26.1.1 (C:\Users\User\AppData\Local\Android\android-sdk)
   NodeJS            : v8.11.4 (C:\Program Files\nodejs\node.exe)
   npm               : 6.9.0
   OS                : Windows 10

ionic cordova platform add android results in an error, seemingly when installing cordova-sqlite-storage …

...
Installing "cordova-sqlite-storage" for android
Failed to install 'cordova-sqlite-storage': CordovaError: Using "requireCordovaModule" to load non-cordova module "q" is not supported. Instead, add this module to your dependencies and use regular "require" to load it.
    at Context.requireCordovaModule (C:\ionic\bthr3\node_modules\cordova-lib\src\hooks\Context.js:57:15)
    at module.exports (C:\ionic\bthr3\plugins\cordova-sqlite-storage\scripts\beforePluginInstall.js:13:21)
    at runScriptViaModuleLoader (C:\ionic\bthr3\node_modules\cordova-lib\src\hooks\HooksRunner.js:181:32)
    at runScript (C:\ionic\bthr3\node_modules\cordova-lib\src\hooks\HooksRunner.js:157:16)
    at C:\ionic\bthr3\node_modules\cordova-lib\src\hooks\HooksRunner.js:125:20
    at <anonymous>
Using "requireCordovaModule" to load non-cordova module "q" is not supported. Instead, add this module to your dependencies and use regular "require" to load it.
    at process._tickCallback (internal/process/next_tick.js:188:7)
[ERROR] An error occurred while running subprocess cordova.

        cordova.cmd platform add android --save exited with exit code 1.

Can someone please enlighten me what I need to do to get this to work again?

OK, I removed cordova-sqlite-storage - not sure why it was there, pretty sure I don’t use it.

Now I’m getting new errors, but I think I can work on them??

The version of cordova-sqlite-storage you were using does not work with the Cordova Android platform version you are using. You could also have upgraded the plugin, or downgraded the platform to fix your problem.

1 Like

Thanks, I haven’t had a chance to try it again yet, if Storage needs sqlite I may have to update this plugin?

OK, restored from backup and all is good again. Not worth my time to try and figure out what I did to break it!

You probably upgraded Cordova Android, which removed the allowed usage of requireCordovaModule in plugins - which is why there is also a new version of the plugin available that fixes this.