0

I've built an Ionic 4 app. Everything works but I get the following error whenever I launch the app in the Chrome debug window from my android device:

Failed to load resource: the server responded with a status of 404 ()
polyfills.js:3040 Unhandled Promise rejection: Error Status 404: App not found ; Zone: <root> ; Task: Promise.then ; Value: Error: Error Status 404: App not found
    at IonicDeployImpl.<anonymous> (/plugins/cordova-plugin-ionic/dist/common.js:291)
    at step (/plugins/cordova-plugin-ionic/dist/common.js:37)
    at Object.next (/plugins/cordova-plugin-ionic/dist/common.js:18)
    at fulfilled (/plugins/cordova-plugin-ionic/dist/common.js:9)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (polyfills.js:2749)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (polyfills.js:2508)
    at polyfills.js:3247
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (polyfills.js:2781)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (polyfills.js:2553)
    at drainMicroTaskQueue (polyfills.js:2959) Error: Error Status 404: App not found
    at IonicDeployImpl.<anonymous> (http://localhost/plugins/cordova-plugin-ionic/dist/common.js:291:35)
    at step (http://localhost/plugins/cordova-plugin-ionic/dist/common.js:37:23)
    at Object.next (http://localhost/plugins/cordova-plugin-ionic/dist/common.js:18:53)
    at fulfilled (http://localhost/plugins/cordova-plugin-ionic/dist/common.js:9:58)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (http://localhost/polyfills.js:2749:26)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (http://localhost/polyfills.js:2508:43)
    at http://localhost/polyfills.js:3247:34
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (http://localhost/polyfills.js:2781:31)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (http://localhost/polyfills.js:2553:47)
    at drainMicroTaskQueue (http://localhost/polyfills.js:2959:35)
api.onUnhandledError @ polyfills.js:3040

I'm not even sure if it's causing any issues. The only real issue I have is when I use Google authentication it takes around 3 minutes to authenticate a user. However, it's a normal time with facebook.

Any help would greatly be appreciated. At this point I've searched Google thoroughly for help with this problem.

This is my app.component

  initializeApp() {
    if (!firebase.apps.length) {
      firebase.initializeApp(firebaseConfig);
      this.platform.ready().then(() => {
        const unsubscribe = firebase.auth().onAuthStateChanged( user => {
          if (!user) {
              this.router.navigateByUrl('login');
              this.statusBar.styleDefault();
              this.splashScreen.hide();
            unsubscribe();
           }  else {
              this.router.navigateByUrl('tabs/itinerary-feed');
              this.statusBar.styleDefault();
              this.splashScreen.hide();
            unsubscribe();
          }
        });

    });
    }
  }

Adding additional information...this runs before I get the error:

Angular is running in the development mode. Call enableProdMode() to enable the production mode.

/plugins/cordova-plugin-fcm-with-dependecy-updated/www/FCMPlugin.js:6 FCMPlugin.js: is created

/plugins/cordova-plugin-fcm-with-dependecy-updated/www/FCMPlugin.js:59 FCMPlugin Ready OK

vendor.js:114077 Ionic Native: deviceready event fired after 910 ms

api.ionicjs.com/apps/588dfcc3/channels/check-device:1 Failed to load resource: the server responded with a status of 404 ()
D.Hodges
  • 1,794
  • 4
  • 24
  • 47

1 Answers1

0

It looks like the build succeeded but some plugin is causing the error.

First, install the latest app-scripts:

npm install @ionic/app-scripts@latest --save-dev

App-scripts are responsible for performing the actual building tasks like:

  • Multi-core processing tasks in parallel for faster builds
  • In-memory file transpiling and bundling
  • Transpiling source code to ES5 JavaScript

Then, remove the node_modules & plugin folder and run "npm install" command again.

Update

initializeApp() 
{
  this.platform.ready().then(() =>  //Fired when Ionic app is ready to listen to device specific events
  {
    this.statusBar.styleDefault();
    this.splashScreen.hide();

    if (!firebase.apps.length) 
    {
      firebase.initializeApp(firebaseConfig);
      const unsubscribe = firebase.auth().onAuthStateChanged( user => {
        if (!user) {
            this.router.navigateByUrl('login');
            //unsubscribe(); //I Can't understand this piece of code. It seems unnecessary here
         }  else {
            this.router.navigateByUrl('tabs/itinerary-feed');
             //unsubscribe();//I Can't understand this piece of code. It seems unnecessary here
        }
      });

    }


  });


}
Pankaj Sati
  • 2,441
  • 1
  • 14
  • 21
  • That didn't work. I added the code for my app.component just in case I made an error in that code. – D.Hodges Feb 04 '20 at 12:26
  • I have updated my answer with the correct way of initializing firebase. Put the code of subscribing to platform ready event outside the "if (!firebase.apps.length)". Platform ready event is fired when the webview on which the ionic app runs is ready. – Pankaj Sati Feb 04 '20 at 12:52
  • Unfortunately same error. I added additional information regarding what happens before the error appears. Could this have anything to to do with ngZone? – D.Hodges Feb 04 '20 at 14:02
  • This is only happening with Android. iOS is working fine – D.Hodges Feb 05 '20 at 03:17
  • Checkout this answer. Maybe it could help. https://stackoverflow.com/a/45885536/10602679 – Pankaj Sati Feb 05 '20 at 04:34
  • I found the solution. It was this plugin causing the error. I removed it and now I'm no longer getting the error: sudo cordova plugin rm cordova-plugin-ionic --save --variable APP_ID="" --variable CHANNEL_NAME="Master" --variable UPDATE_METHOD="background" – D.Hodges Feb 08 '20 at 23:44