【问题标题】:error 404 Ionic Deploy Impl http://localhost/plugins/cordova-plugin-ionic/dist/common.js错误 404 离子部署 Impl http://localhost/plugins/cordova-plugin-ionic/dist/common.js
【发布时间】:2020-05-19 18:09:43
【问题描述】:

我已经构建了一个 Ionic 4 应用程序。一切正常,但每当我从我的 android 设备在 Chrome 调试窗口中启动应用程序时,我都会收到以下错误:

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

我什至不确定它是否会导致任何问题。我唯一真正遇到的问题是,当我使用 Google 身份验证时,大约需要 3 分钟来验证用户身份。但是,这是使用 facebook 的正常时间。

任何帮助将不胜感激。在这一点上,我已经彻底搜索了谷歌以寻求解决这个问题的帮助。

这是我的 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();
          }
        });

    });
    }
  }

添加其他信息...在我收到错误之前运行:

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 ()

【问题讨论】:

    标签: cordova ionic-framework cordova-plugins ionic4


    【解决方案1】:

    看起来构建成功,但某些插件导致错误。

    首先,安装最新的应用脚本:

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

    应用脚本负责执行实际的构建任务,例如:

    • 并行处理多核任务以加快构建速度
    • 内存中 文件转译和打包
    • 将源代码转译为 ES5 JavaScript

    然后,删除 node_modules & plugin 文件夹并再次运行“npm install”命令。

    更新

    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
            }
          });
    
        }
    
    
      });
    
    
    }
    

    【讨论】:

    • 那行不通。我为我的 app.component 添加了代码,以防我在该代码中出错。
    • 我已经用初始化 firebase 的正确方法更新了我的答案。将订阅平台就绪事件的代码放在“if (!firebase.apps.length)”之外。当运行 ionic 应用的 webview 准备就绪时,会触发平台就绪事件。
    • 不幸的是同样的错误。我添加了有关错误出现之前发生的情况的其他信息。这和 ngZone 有什么关系吗?
    • 这只发生在 Android 上。 iOS 运行良好
    • 查看这个答案。也许它会有所帮助。 stackoverflow.com/a/45885536/10602679
    猜你喜欢
    • 2017-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-24
    • 1970-01-01
    • 2018-03-02
    相关资源
    最近更新 更多