Ionic apk build errors

I’m trying to add platform so that i can build apk file for my app

C:\sudafax> cordova platform add android
Using cordova-fetch for cordova-android@^6.4.0
Adding android project...
Creating Cordova project for the Android platform:
        Path: platforms\android
        Package: com.sudafax.dailynews
        Name: ________
        Activity: MainActivity
        Android target: android-26
Subproject Path: CordovaLib
Android project created with cordova-android@6.4.0
config file *-Info.plist requested for changes not found at F:\Ionic\New\sudafax\platforms\android\*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at F:\Ionic\New\sudafax\platforms\android\*-Info.plist, ignoring
Installing "cordova-admob-sdk" for android
Subproject Path: CordovaLib
Installing "cordova-android-play-services-gradle-release" for android
Subproject Path: CordovaLib
Failed to install 'cordova-android-play-services-gradle-release': 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:\Users\Codedev\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\Context.js:57:15)
    at module.exports (F:\Ionic\New\sudafax\plugins\cordova-android-play-services-gradle-release\scripts\apply-changes.js:87:20)
    at runScriptViaModuleLoader (C:\Users\Codedev\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:181:32)
    at runScript (C:\Users\Codedev\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:157:16)
    at C:\Users\Codedev\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:125:20
    at process._tickCallback (internal/process/next_tick.js:68:7)
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.

Can you provide some system info?
Copy paste result of ionic info command please

i did some changes to an old ionic app and trying to build it again

cli packages: (C:\Users\Codedev\AppData\Roaming\npm\node_modules)

    @ionic/cli-utils  : 1.9.2
    ionic (Ionic CLI) : 3.9.2

global packages:

    Gulp CLI : not installed globally

local packages:

    Ionic Framework : ionic1 1.3.1

System:

    Node : v10.15.3
    npm  : 6.9.0
    OS   : Windows 10

I had some issues updating an old app too lately.

Update your Ionic and Cordova
npm i -g ionic cordova

Delete ALL build files and rebuild your project.

rm -rf plugins/ platforms/ www/
ionic cordova platform rm android
ionic cordova platform add android

With some luck only these few steps might do the trick…

I changed some strings only on this old app

what about file structure for this old app ? i’m afraid if updated ionic the app can’t serve anymore.

because i removed ionic 4 and installed old version to let this app work (serve )

With the ‘Ionic 4’ CLI you still will be able to build/serve or whatever with your Ionic 3 app. The thing is, when building for an platform the CLI is using some up-to-date ‘rules’ to create and/or build a platform project/file. Your ‘project-files’ are outdated and therefor not working anymore when building again. (simply said)

Therefore it looks like you’ll have to update your Ionic and Cordova and maybe make some small adjustments. You can always downgrade your Ionic and Cordova to whatever version you want. If you’re affraid of trying, just backup your Ionic project.

Same error i updated cordova ionic , also did all changes in this post

cordova platform add android
Using cordova-fetch for cordova-android@^8.0.0
Adding android project...
Creating Cordova project for the Android platform:
        Path: platforms\android
        Package: com.sudafax.dailynews
        Name: ________
        Activity: MainActivity
        Android target: android-28
Subproject Path: CordovaLib
Subproject Path: app
Android project created with cordova-android@8.0.0
config file *-Info.plist requested for changes not found at F:\Ionic\New\sudafax\platforms\android\*-Info.plist, ignoring
config file *-Info.plist requested for changes not found at F:\Ionic\New\sudafax\platforms\android\*-Info.plist, ignoring
Installing "cordova-admob-sdk" for android
Subproject Path: CordovaLib
Subproject Path: app
Installing "cordova-android-play-services-gradle-release" for android
Failed to install 'cordova-android-play-services-gradle-release': 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:\Users\Codedev\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\Context.js:57:15)
    at module.exports (F:\Ionic\New\sudafax\plugins\cordova-android-play-services-gradle-release\scripts\apply-changes.js:99:20)
    at runScriptViaModuleLoader (C:\Users\Codedev\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:181:32)
    at runScript (C:\Users\Codedev\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:157:16)
    at C:\Users\Codedev\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:125:20
    at process._tickCallback (internal/process/next_tick.js:68:7)
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.

You also did delete the folders platforms/ plugins/ and www/?

By the way, I’ve missed in your error log that you’re using cordova-android-play-services-gradle-release. Delete cordova-android-play-services-gradle-release from your config.xml and package.json

Perform a npm update (updating all packages to ‘wanted’ version)
npm update

And give it another try…

Thanks Bilow

i followed your instructions and also the link above

here are some steps that i did :

1 always do npm cache clean
2- ionic cordova platform add android ( with removing folders and files you mentioned ).

and with some luck i succeeded .

thanks

1 Like