--release produces corrupted apk

steps to re-produce:

  1. start new project, select the one “super”
  2. cd into the folder, don’t change any code
  3. $ ionic cordova platform add android
  4. $ ionic cordova build android --prod --release

the apk produced is corrupted.
btw --prod only app works fine.
–prod --release ios app works fine.

node -v 8.1.2
ionic -v 3.4.0
Testing device: android version 7.0

To see that, try to install the apk on ur android phone. The installation will fail with the message “corrupted apk”

1 Like

What is your ionic info output?

global packages:

@ionic/cli-utils : 1.4.0
Cordova CLI      : 7.0.1
Ionic CLI        : 3.4.0

local packages:

@ionic/app-scripts              : 1.3.7
@ionic/cli-plugin-cordova       : 1.4.0
@ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms               : android 6.2.3
Ionic Framework                 : ionic-angular 3.4.0

System:

Node       : v8.1.2
OS         : macOS Sierra
Xcode      : Xcode 8.2.1 Build version 8C1002
ios-deploy : not installed
ios-sim    : 5.0.13
npm        : 5.0.3

Can you test --release without --prod as well?

Just tried. --release only android app apk is corrupted as well.

Any customization of the build process or anything?

No. I clone the app fresh. didn’t change anything at all. The cli is also freshly upgraded and installed. I found this because my own apk is facing the same problem. I didn’t change build process for that one as well. That’s why i started a sample app to test.

I am already in the weekend, hopefully someone will be able to retest this on his machine and confirm that this is not a general problem but only on your machine.

Thank you for taking ur weekend time to reply me. I will ask my colleagues to try as well.

I have one of my colleague tested. He did the same thing and got the same corrupted apk.

You can refer to this tutorial on how to genrate release apk…and signed apk too.

You got me wrong. Ionic home page has very clear instruction on how to do that. And the video is from 2 years ago. The problem I’m facing now is that cli --release generates an corrupted apk, even for sample app directly from ionic repository without any code change. That means the build tool is bugged. All the developers out there with this version of ionic will not be able to publish their app until this issue is fixed.

1 Like

I am working with cli 3.3.0 it works fine…you can try that version…I am working on windows…

In your steps to reproduce the problem I didn’t see any references to the certificates. Did you produce the certificate for the apk signature?

I mean --release tell cordova to sign the apk. If there are no certificates to sign the apk that could be the problem?

if you check the documentation here at ionic home page http://ionicframework.com/docs/intro/deploying/

it says i can build --prod --release apk first then sign it later

Oki doki, I didn’t know then …

But anyway for me, --release = sign android app = I want to release my app in google play store with a valid certificate

The rest of the time, I just don’t use --release

Do you both also get a “corrupted” apk when building the blank template or is it only the super one?
How exactly do you define corrupted by the way? I never asked…

I only tried the “super” template. And my own app faces the same problem. The definition of “corrupted apk” is that when u click that apk in the android phone, the install will fail with a message “corrupted apk”. the build process reported no problem.

Compare a corrupted and uncorrupted file locally please - you can just rename it to .zip and unpack the content.

I tried the unzip thing it works. I got some webapp back. How am I supposed to compare? what should I look for? and I don’t really have uncorrupted apk though. since all the builds are corrupted.