Ionic app doesn't even launch

Hi,

I’m trying to build my app for android, so I used the command

  ionic cordova build android --release

And launched the app successfully. However, it was taking around 20 seconds, so I uninstalled this version and created another build using this command :

  ionic cordova build android --prod

This build of the app didn’t even launch, let alone reduce launch time. When I uninstalled this version and tried to run the first version of the app with the --release flag, which did launch the first time like I said, I had the same issue. Even this version of the app wasn’t launching and it was forever showing a blank white screen.

No changes were made to the code when I was building these versions of the app. So why has my release apk suddenly stopped working after replacing it with a prod version and then again replacing it back to the release version? Why did the release version stop working after doing this?

Because you broke something.

Post your ionic info.

--release and --prod are not opposites.
--release is the opposite of --debug which is the default.
--prod is an additional flag that triggers a production build.
If you want to release your app, you should use both: --prod --release.

If something doesn’t work, you can debug it or see the error output during the output.

@ionic/cli-utils  : 1.12.0
ionic (Ionic CLI) : 3.12.0

global packages:

cordova (Cordova CLI) : 7.0.1

local packages:

@ionic/app-scripts : 2.0.0
Cordova Platforms  : android 5.2.2
Ionic Framework    : ionic-angular 3.5.0

System:

Android SDK Tools : 23.0.0
Node              : v7.7.3
npm               : 4.1.2
OS                : Windows 10

Misc:

backend : legacy

All old and outdated. Biggest problem is probably app-scripts and cordova-android.

What command would update all of these?

Would really like some help with this… does anyone know the latest versions I should be having and what command would update them? I tried updating ionic but that didn’t work

Hi,

I found the issue : I was conditionally setting the rootPage of the app depending on the value in storage. Since there were no values in storage after relaunching the app, there was no rootPage that was defined, so that’s why I got a blank screen. Thank you for the help though :slight_smile:

There’s nothing fundamentally wrong with this technique, but IMHO any property that is accessed by a template needs to be initialized at the point of its definition to something sane.

1 Like
this.storage.get('CurrentUser').then((data)=>{
 if(data["Type"]=="NGO"){
   this.rootPage = NgoRequestPage;
 }
 else
 if(data["Type"]=="Donor"){
   this.rootPage = DonorHomePage;
 }
 else{
   this.rootPage = HomePage;
 }
});

Hmm, any suggestions on how I can improve this snippet of code?

Nope, because what I’m suggesting is that where rootPage is declared, it should be initialized to some viable default, even if it’s an empty placeholder loading page.

Like this ?

 rootPage:any=HomePage;

Basically, assuming that HomePage is something you don’t mind accidentally flickering on startup occasionally. Probably not very likely in the real world.

Actually, this is exactly how I set it up at first, and I did see the flickering of the HomePage like you said. I didn’t find it very attractive, so I changed the code. But is there a chance that it won’t flicker?

Really depends on the speed of the device. Can you make a secondary splash page that you wouldn’t mind having flicker in and use that as the initializer?

I think that’s a good idea. I was thinking that I could maybe show a page with the logo of my app. Make that the default rootPage, and then my code will accordingly change the rootPage. Your thoughts?

Sounds like a great plan to me.

1 Like

Awesome! Thanks for the helpful tip :slight_smile: