ionic-team / ionic-app-scripts

App Build Scripts for Ionic Projects
http://ionicframework.com/
MIT License
609 stars 300 forks source link

build android with --prod and --release make unstable app #758

Open soniyj opened 7 years ago

soniyj commented 7 years ago

Note: for support questions, please use one of these channels:

https://forum.ionicframework.com/ http://ionicworldwide.herokuapp.com/

Short description of the problem:

Building an Android apk using both the flags --prod and --release makes an unstable apk, meaning that the ionic Deploy service it's always undefined and if you open and close the app several times most of the cordova plugins are not loaded with the error cordova not loaded.

This doesn't happen in debug mode (ionic build android) and also with ionic build android --release ionic build android --prod ionic build android --prod --aot

What behavior are you expecting?

The app to run without any problem

Steps to reproduce:

  1. Create an ionic v2 side menu app
  2. add any cordova plugin (eg OneSignal) and add ionic deploy
  3. Build the app using ionic build android --release --prod
  4. Install and run on device
insert any relevant code between the above and below backticks

Which @ionic/app-scripts version are you using? "@ionic/app-scripts": "1.1.0" "typescript": "2.0.9"

Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc) http://stackoverflow.com/questions/42269507/ionic-2-android-release-app-not-working/42270171#42270171

ghenry22 commented 7 years ago

I build my app with ionic build android --prod --release without issue.

The two switches are doing different things.

--prod is setting variables for optimizing the ionic2 build (aot, uglify, minify etc) --release tells the android compiler to generate a release apk and not a debug apk.

a debug apk cannot be signed and published to the app store so without the --release you cannot release your app.

I don't use ionic deploy at all though.

soniyj commented 7 years ago

Hi @ghenry22

I have used different ionic app script version 1.0.1 and 1.1.1 and in both cases adding --prod or --aot will make an unstable apk, while using just --release will work.

I know that a debug version cannot be published on the store, it is not my first app.

So having done different tests I can say that it's a problem of the building script.

ghenry22 commented 7 years ago

Perhaps it is a combination of the app script and something else, I use --prod and --release on my builds with no issues. Have been using app scripts 1.0.0 as no formal statement has been given by ionic prompting an update. I just updated to 1.1.2 , I'll try an android build on Monday and see if it works or has odd results.

soniyj commented 7 years ago

I will update to the 1.1.2 as well and see if the problem is still there.

jstoup111 commented 7 years ago

@soniyj is the issue still there with 1.1.2?

soniyj commented 7 years ago

I am using the 1.1.4 and the problem it is still there. Not sure if it could be related to the npm or so, as soon as I got time I will try to create a VM and see if it works there.

santamaria7 commented 7 years ago

I'm experiencing the same problem. The build process is successful but the generated apk cannot be installed on a real device and I get "Ap was not installed" message on the device. ionic 3.0.0 angular 4.x app scripts 1.3.7

santamaria7 commented 7 years ago

I just signed the released unsigned apk and it worked.

soniyj commented 7 years ago

@jstoup111 the problem is still there with 1.1.4 Ionic 2.2.1. I didn't update due to legacy projects, but I will in the next upcoming months.

ghenry22 commented 7 years ago

I am running android builds and publishing them without issue using --prod --release. I have several cordova plugins install and no problems with stability or successive launches. However, I don't use ionic deploy. Perhaps it is a problem specific to that plugin?

soniyj commented 6 years ago

I will test this with the new ionic 3 and scripts to see what happens

vidakovic commented 6 years ago

Same problem here. I've tried to debug the issue but get only (recorded with sentry.io):

[object ErrorEvent]

--release works, but as soon as I put --prod I get the above.

The funny thing is that at one point (my first deployment) it was working with all bells and whistles (--prod) turned on. So I suspect this is less of a bug in the build scripts than something I am ignoring (AOT incompatible code?).

Any ideas how to squeeze more infos out of the app?

soniyj commented 6 years ago

@vidakovic did you tried with the new scripts? I am not saying that is working but I migrated the code to ionic 3 using the latest version, hoping that is going to fix this.

vidakovic commented 6 years ago

it's working now for me now... just fyi

soniyj commented 6 years ago

hi @vidakovic cool, I will give a go as I made a new app with Ionic 3, I will keep you posted.

smasherprog commented 6 years ago

I am having the same issue. If I build locally a release build of android and deploy to the store the live deploy will not work. I restart my app several times and it never installs the updates. However, if i build through Ionic's build system and use that for the play store, the live deploy works..