--release produces corrupted apk

I was only aware of npm5+Windows problems, and these exist until a new release ap app-scripts >1.3.7.
As OP is not using Windows I assumes he was good… maybe not.

I used yarn for the package manager though. node-sass isn’t a problem. The build went smoothly, no reporting of errors throughout the whole thing. And the build was successful. That’s the problem right.

1 Like

My suggestion is that you open a GitHub issue. This feels like a question for the devs. Also, I think you might want to install nvm (Node Version Manager), install the current Node LTS, and see if you get the issue when building with the LTS. Both npm 5 and Cordova 7 are new, so maybe there’s an issue in how they communicate.

1 Like

I am having the same problem.

with flag --release, apk file gets corrupted.

with out --release for example below commend works fine.

ionic cordova build android --prod
ionic cordova build android

but below creates corrupted apk file.

ionic cordova build android --prod --release

I am in process of testing this corrupted apk works fine after posting to Google play store.
I have posted the app, and waiting for update.

This is my ionic info

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.2

System:

    Node       : v6.11.0
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.3 Build version 8E3004b 
    ios-deploy : not installed
    ios-sim    : not installed
    npm        : 3.10.10 

App Script

"@ionic/app-scripts": "1.3.7",

Ok, so even the apk file is corrupted while using --release. (Maybe it isn’t corrupted, it just doesn’t allow installation??)

It works after posting to google play store and download the app.

well what can I say. I guess you just have to wait for enough people to run into the issue before they start fixing it.

There is a newer version of this available now.

If the problem persists you best bet is to create an issue with Ionic CLI I think: Issues · ionic-team/ionic-cli · GitHub

i have the exact same problem

I’m seeing the exact same problem.

ionic 3.5.0
MacOS Sierra
node v7.5.0
cordova 6.5.0

Dudes,

maybe you’re missing something. If you do not sign your .apk that has been flagged as --release, it won’t work.

Give it a try, sign the .apk and test again, I hope it works.

Regards,
Arthur

3 Likes

Thanks @arthurquites

I just experienced this problem with the current version of Ionic and dependencies:
ionic: 3.19.0
Cordova: 7.1.0
"cordova-android": “6.3.0”,
“ionic-angular”: “3.9.2”
@ionic/app-scripts": “3.1.5”

Signing the apk definitely worked for me. [https://ionicframework.com/docs/intro/deploying/]

1 Like

I also have the same problem. But my debug apk gets corrupted. I used ionic cordova build android and got corrupted apk. Can you please help?

I got the same issue as well.

Without --release the apk can be installed, but with --release the apk can not be installed.

I also signed it and zipalign to create a signed apk, but still can not be installed.

The only thing is that I did not try to upload it to google play, but I think it will not help anything.

So anyone can help regarding this, what cause this and how to solve, thanks.

I had the same issue but was able to fix it.

I think the problem might be not installing the corresponding system image (arm 7 in my case) for the target api level. I installed it and everything is working fine.

Also, if you are using the crosswalk plugin, I ran into another related issue where the compiler complained about missing font assets or something. After some googling I found a simple solution which worked for me: Add the following bit to your build-extras.gradle (or if it’s not there simply make the file and add it to platforms/android, or wherever your build.gradle is):

configurations.all {
    resolutionStrategy {
        force 'com.android.support:support-v4:25.1.1'
    }
}

And be sure to install the system image for the api listed in this file and update all relevant apis and also the android support repository.

Finally, reinstall ionic, cordova, gradle if need be. I found out indirectly, for some reason my cordova installation had become corrupted. So maybe try that first?

the problem persist, here is my inic info:
fabio@fabio-PC:~/Documents/Ingenisoft/sekret/myApp$ ionic info
:heavy_check_mark: Gathering environment info - done!

Ionic:

ionic (Ionic CLI) : 4.1.1 (/usr/lib/node_modules/ionic)
Ionic Framework : ionic-angular 3.9.2
@ionic/app-scripts : 3.2.0

Cordova:

cordova (Cordova CLI) : 8.0.0
Cordova Platforms : android 7.0.0
Cordova Plugins : cordova-plugin-ionic-keyboard 2.1.2, cordova-plugin-ionic-webview 2.1.0, (and 4 other plugins)

System:

Android SDK Tools : 26.1.1 (/home/fabio/Android/Sdk)
NodeJS : v8.11.3 (/usr/bin/node)
npm : 6.4.0
OS : Linux 4.15

Im on Deepin OS 15.7 of 64bits based on debian 8, my laptop is a ASUS STRIX

facing same issue. the apk file has been corrupted after creating release build

I had the exact same issue.
However --prod build works just fine.
For release, if you sign the apk the problem vanishes.
Not sure of the reasons.

keytool -genkey -v -keystore testapk.keystore -alias testapk -keyalg RSA -keysize 2048 -validity 10000
keytool -importkeystore -srckeystore testapk.keystore -destkeystore testapk.keystore -deststoretype pkcs12

after second command run keystore file changed and problem solved

1 Like

Thanks a lot @rupendra1 You saved my life!! :smiley:

1 Like

welcome [5hivam] any time