Ionic App Fails to Run Only When Installing as Production Build

I have an app that runs fine on my Galaxy S6 when it is installed via “ionic cordova run android” but when I install it using ionic cordova run android --prod, it shows the splash screen, then switches to an all white screen and just hangs there. I launched the Android monitor to see if any of the logging might help but nothing jumps out at me as being a problem. I was using Crosswalk and then thought perhaps there was an issue with that so I removed Crosswalk and deployed it again but with the same result. I’m fairly new to Ionic as this is my first Ionic app.

Has anyone experienced an issue like this? Does anyone have any suggestions regarding how to troubleshoot this? Maybe logging that I might be unaware of, things to check, etc.? Right now I’m looking for a good starting point.

Thank you in advance!

1 Like

Try connecting the mobile to the computer and using Google Chrome developer window to
find out what is happening to the App on the mobile device.

Thanks. The very interesting thing is that it appears to never launch the Webview because when I run it by installing from my machine, I get the option to inspect it. However, when I run from the installed version from the play store, it never gives me this option so it appears that it never launches the webview. At least that gets me closer to the actual problem even though I still have no idea what’s going on.

Release versions (built with --release) are not debuggable. That is why they don’t appear in the Chrome Inspect menu (which also makes it hard to debug these problems…)

Thanks. I was pretty sure that was the case. Do you know if it is possible to upload a debug version to the play store? I’m in the fortunate position of not yet having anyone other than beta users so I can play with this a little bit without impacting my user base.

I don’t think so.

Which command did you use to build your debug builds you tested?
Which command did you use to build the broken release build?

The debug build was:
ionic cordova run android

The release build used:
ionic cordova build android --release --prod

Try to build one with ionic cordova run android --prod and see if this works.

Well, the “good” news is that when I do ionic cordova run android --prod it also fails as well. This means I can test various things without going through the play store. I can’t believe I didn’t think to try this from the get go. So, now to see what I can find out.

1 Like

Yeah, the difference between --prod and --release is not very well documented (and these are also not very good names for the functionality behind it…)

Thanks for chiming in on this issue. I’ve basically decided to create a new project and drop piece by piece from my project into the new one until I break the new one so I can find the culprit. I will definitely update this thread when I have found my solution.

1 Like

Follup on this issue. This was incredibly strange. After hours of experimentation, attempts to locate the culprit because no errors were occurring, and trial and error, I finally tried something drastic. I created a brand new Ionic 3 project using the blank template. I then installed all necessary Cordova and npm plugins that my project needed. I then began copying my project files in piece by piece, rebuilding with --prod each step, saving a backup each time when I had a working build. I copied in a few of the first pages of my app but did not copy in my modified variables.scss file. Things ran fine other than the ugly UI since it was missing the variables for styling. When I copied in my variables.scss file, I decided to go ahead and rebuild with only that change. Sure enough, it was broken. Built with a standard debug build and all worked fine. Very strange. But in any case, this pointed to that file as a problem. So then I copied back the blank project version and all worked again so I then began adding in my changes a few at a time. It then had the problem again. I thought it was due to some specific variables, but it turned out that it seems to have something to do with the number of variables I had added in the $colors map. I didn’t have a huge number but it actually was a little cluttered from some variables I was no longer using so I consolidated and cleaned that up and now, everything is working fine.

So, I have no explanation and I already spent way too much time on this to dig into it to try to pinpoint the exact cause, but I did want to update this thread just in case someone else ever hits the same or similar issue.

2 Likes

Likely related thread.

Thanks for adding that link. I wish I’d found that one a couple days ago.