Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic CLI not generating release build for Android

When I use the command: cordova build --release android the CLI throws the following error:

Error: Cannot find module 'minimatch'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:286:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object.<anonymous> (C:\Users\sologic\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\node_modules\glob\glob.js:44:17)
    at Module._compile (module.js:434:26)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)

But when I use Ionic Lab (Windows Installer) and using the Build option - it generates 'android-debug.apk' & 'android-debug-unaligned.apk' in the android\build\outputs\apk folder.

Note that it is not generating android-release-unsigned.apk

My questions are:

1: What is wrong with the CLI ??

2: can I use the android-debug-unaligned.apk for Signing (with jarsigner) and Aligning (with zipalign ) for submitting on Google Play ??

Please advice.

like image 472
Arup Bhattacharya Avatar asked Apr 15 '26 13:04

Arup Bhattacharya


1 Answers

  1. Nothing went wrong with IONIC CLI at this time (v1.7.6), because I'm using it every day.

    • Check your CLI version by this command ionic --version and see if your version is lower than 1.7.6.
    • If your CLI is old, run npm install -g ionic again to install the lasted version of Ionic CLI.
    • If not, try to re-create all new project, and try to build again with, if it OK, just because of your project:
      • ionic start appName blank
      • ionic platform add android
      • ionic build android --release
  2. You can't use the debug apk for Google Play because they can read your APK and check if is is debug or release version. But I think you can set the debug mode in your AndroidManifest.xml to false and try like this:

    • Add android:debuggable="false" to the <application> element.
    • More info : Using Hardware Devices.
  3. Ionic also provide a package cloud service very helpful for non-plugin project inside the Ionic CLI. It can build all your project in the cloud in a minute and you can download the apk anytime.

    • cd to your ionic project folder by Ionic CLI.
    • Run ionic package build android an wait for the progress to done.
    • Run ionic package list to get the list and see the status if it has been done the building progress.
    • Run ionic package download [id] to download your apk to your project folder. id is the number you see in the list.
    • These commands will help you build the debug apk, for the release version, check this ionic.io package documents to build with profile (keystore).
like image 137
Nam Pham Avatar answered Apr 18 '26 02:04

Nam Pham