Ionic Package can't generate APK

Ionic Package can’t generate APK for Ionic V1, probably because Ionic Package updated Cordova CLI or something like that.

Package Build 6489830

This is the error message I get:

Discovered saved plugin “cordova-sqlite-storage”. Adding it to the project
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 (/usr/local/lib/node_modules/@ionic-enterprise/cordova/node_modules/@ionic-enterprise/cordova-lib/src/hooks/Context.js:57:15)
at module.exports (/builds/project-0/plugins/cordova-sqlite-storage/scripts/beforePluginInstall.js:13:21)
at runScriptViaModuleLoader (/usr/local/lib/node_modules/@ionic-enterprise/cordova/node_modules/@ionic-enterprise/cordova-lib/src/hooks/HooksRunner.js:181:32)
at runScript (/usr/local/lib/node_modules/@ionic-enterprise/cordova/node_modules/@ionic-enterprise/cordova-lib/src/hooks/HooksRunner.js:157:16)
at /usr/local/lib/node_modules/@ionic-enterprise/cordova/node_modules/@ionic-enterprise/cordova-lib/src/hooks/HooksRunner.js:125:20
at
at process._tickCallback (internal/process/next_tick.js:189:7)
Failed to restore plugin “cordova-sqlite-storage” from config.xml. You might need to try adding it again. Error: 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.

If I try to update to most recent 2.* which is 2.6.0 or even 2.5.2, Ionic Package cannot generate APK with the same error message above.

If I follow Ionic Package’s suggestion to update cordova-sqlite-storage package from 2.5.0 to 3.2.0 (most recent) the apk is generated, successfully installed, app opens but than crashes, with the folowwing error message:

E/PluginManager( 2378): Uncaught exception from plugin
E/PluginManager( 2378): java.lang.SecurityException: ConnectivityService: Neither user 10105 nor current process has android.permission.ACCESS_NETWORK_STATE.
E/PluginManager( 2378): at android.os.Parcel.readException(Parcel.java:1465)
E/PluginManager( 2378): at android.os.Parcel.readException(Parcel.java:1419)
E/PluginManager( 2378): at android.net.IConnectivityManager$Stub$Proxy.getActiveNetworkInfo(IConnectivityManager.java:817)
E/PluginManager( 2378): at android.net.ConnectivityManager.getActiveNetworkInfo(ConnectivityManager.java:565)
E/PluginManager( 2378): at org.apache.cordova.networkinformation.NetworkManager.execute(NetworkManager.java:130)
E/PluginManager( 2378): at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:98)
E/PluginManager( 2378): at org.apache.cordova.PluginManager.exec(PluginManager.java:132)
E/PluginManager( 2378): at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
E/PluginManager( 2378): at org.apache.cordova.engine.SystemExposedJsApi.exec(SystemExposedJsApi.java:41)
E/PluginManager( 2378): at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
E/PluginManager( 2378): at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:24)
E/PluginManager( 2378): at android.os.Handler.dispatchMessage(Handler.java:102)
E/PluginManager( 2378): at android.os.Looper.loop(Looper.java:136)
E/PluginManager( 2378): at android.os.HandlerThread.run(HandlerThread.java:61)

Found this issue on GitHub but I cannot do anything about Ionic Package, any recommendations?

This is my Ionic Info output:

$ ionic info
[WARN] The pro_id field in ./ionic.config.json has been deprecated.
       
       Ionic Pro has been renamed to Ionic Appflow! We've copied the value in pro_id to id, but you may want to unset 
       the deprecated property: ionic config unset pro_id
       

Ionic:

   ionic (Ionic CLI) : 4.8.0
   Ionic Framework   : ionic1 1.2.4
   @ionic/v1-toolkit : 1.0.17

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : none
   Cordova Plugins       : no whitelisted plugins (1 plugins total)

System:

   Android SDK Tools : 26.0.2 (/home/edson/Android/Sdk)
   NodeJS            : v10.14.1 (/home/edson/.nvm/versions/node/v10.14.1/bin/node)
   npm               : 6.4.1
   OS                : Linux 4.15

I fixed the problem by keeping the most recent version from cordova-sqlite-plugin and did the following:

  • Removed contents from the folders: plugins, node_modules and platforms
    • rm -rf plugins/*
    • rm -rf node_modules/*
    • rm -rf platforms/*
  • Reinstalled ionic
    • npm rm ionic
    • npm add ionic
  • Updated to most recent android version
  • Added below permissions to config.xml
    • <uses-permission android:name="android.permission.INTERNET" />
    • <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />