首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >空白屏幕-角JIT编译失败:“@转角/编译器”未加载

空白屏幕-角JIT编译失败:“@转角/编译器”未加载
EN

Stack Overflow用户
提问于 2021-11-24 14:52:13
回答 1查看 275关注 0票数 0

我目前有困难,使我的Ionic 5和角9项目的工作。

ionic cordova run android工作得很好

但是当我运行ionic cordova run android --prod时,唯一能得到的就是一个空白的屏幕。

来自铬开发工具的输出:

代码语言:javascript
复制
Error: Angular JIT compilation failed: '@angular/compiler' not loaded!
  - JIT compilation is discouraged for production use-cases! Consider AOT mode instead.
  - Did you bootstrap using '@angular/platform-browser-dynamic' or '@angular/platform-server'?

  - Alternatively provide the compiler with 'import "@angular/compiler";' before bootstrapping.
    at J (main-es2015.a75ef42b05ed5a68eecb.js:1)
    at Function.get (main-es2015.a75ef42b05ed5a68eecb.js:1)
    at Gt (main-es2015.a75ef42b05ed5a68eecb.js:1)
    at Ji (main-es2015.a75ef42b05ed5a68eecb.js:1)
    at main-es2015.a75ef42b05ed5a68eecb.js:1
    at Yi.processProvider (main-es2015.a75ef42b05ed5a68eecb.js:1)
    at main-es2015.a75ef42b05ed5a68eecb.js:1
    at main-es2015.a75ef42b05ed5a68eecb.js:1
    at Array.forEach (<anonymous>)
    at Ot (main-es2015.a75ef42b05ed5a68eecb.js:1)

我已经检查了以下解决方案方法,但这些方法都不适合我的项目:

如果我将aot和buildOptimizer设置为angular.js中的false,我可以运行ionic cordova run android --prod而不会出现任何错误,但是当我尝试用ionic cordova build android --prod --release生成一个apk并打开它时,屏幕又是空白的。

我在package.json中的当前依赖项是:

代码语言:javascript
复制
  "dependencies": {
    "@angular/common": "~9.1.6",
    "@angular/core": "~9.1.6",
    "@angular/forms": "~9.1.6",
    "@angular/platform-browser": "~9.1.6",
    "@angular/platform-browser-dynamic": "~9.1.6",
    "@angular/router": "~9.1.6",
    "@auth0/angular-jwt": "^4.1.2",
    "@capacitor/core": "3.0.0",
    "@ionic-native/app-version": "^5.36.0",
    "@ionic-native/core": "^5.36.0",
    "@ionic-native/device": "^5.36.0",
    "@ionic-native/in-app-browser": "^5.36.0",
    "@ionic-native/ionic-webview": "^5.36.0",
    "@ionic-native/local-notifications": "^5.36.0",
    "@ionic-native/native-audio": "^5.36.0",
    "@ionic-native/network": "^5.36.0",
    "@ionic-native/screen-orientation": "^5.36.0",
    "@ionic-native/splash-screen": "^5.36.0",
    "@ionic-native/status-bar": "^5.36.0",
    "@ionic/angular": "^5.0.0",
    "@ionic/storage": "^2.3.1",
    "@types/google-maps": "^3.2.2",
    "@types/hammerjs": "^2.0.39",
    "compare-func": "^2.0.0",
    "cordova-android": "^9.0.0",
    "cordova-ios": "^5.1.1",
    "cordova-plugin-androidx": "^2.0.0",
    "cordova-plugin-androidx-adapter": "^1.1.1",
    "cordova-plugin-app-version": "^0.1.9",
    "cordova-plugin-badge": "^0.8.8",
    "cordova-plugin-device-name": "^1.3.5",
    "cordova-plugin-fcm-with-dependecy-updated": "^7.3.1",
    "cordova-plugin-inappbrowser": "^4.1.0",
    "cordova-plugin-ionic-webview": "^5.0.0",
    "cordova-plugin-local-notification": "^0.9.0-beta.2",
    "cordova-plugin-nativeaudio": "^3.0.9",
    "cordova-plugin-network-information": "^2.0.2",
    "cordova-plugin-screen-orientation": "^3.0.2",
    "cordova-plugin-wkwebviewxhrfix": "git+https://github.com/TheMattRay/cordova-plugin-wkwebviewxhrfix.git",
    "cordova-support-google-services": "^1.3.2",
    "es6-promise-plugin": "^4.2.2",
    "hammerjs": "^2.0.8",
    "ionic-pullup": "^5.0.0-beta.3",
    "ionic2-calendar": "^0.6.9",
    "phonegap-plugin-multidex": "^1.0.0",
    "rxjs": "~6.5.1",
    "rxjs-compat": "^6.5.5",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  },

M<环境如下所示:

代码语言:javascript
复制
Ionic:

   Ionic CLI                     : 5.4.16 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 5.9.1
   @angular-devkit/build-angular : 0.901.15
   @angular-devkit/schematics    : 9.1.15
   @angular/cli                  : 9.1.15
   @ionic/angular-toolkit        : 2.3.3

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : android 8.1.0, ios 5.1.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, (and 18 other plugins)

我是不是遗漏了什么?欢迎任何帮助!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-11-28 13:49:37

在遵循这些步骤之后,我让一切都正常运转:

  • 重命名为node_modules、www和platforms/android (出于备份原因)
  • npm安装
  • 离子cordova准备android
  • 离子cordova运行android-prod
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70098226

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档