angular - Nativescript + Angular -> 错误:无法解析 ApplicationModule 的所有参数:(?)
问题描述
所以我确实按照我一直在做的 NS 更新说明升级了我的 nativescript+angular 应用程序。但是这一次,在构建应用程序之后,当我尝试打开它时,会抛出以下错误
System.err: An uncaught Exception occurred on "main" thread.
System.err: Unable to start activity ComponentInfo{pt.XX.YY/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreate failed
System.err: Error: Can't resolve all parameters for ApplicationModule: (?).
System.err:
System.err: StackTrace:
System.err: java.lang.RuntimeException: Unable to start activity ComponentInfo{pt.XX.YY/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: Calling js method onCreate failed
System.err: Error: Can't resolve all parameters for ApplicationModule: (?).
System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3430)
System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3614)
System.err: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:86)
System.err: at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
System.err: at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2199)
System.err: at android.os.Handler.dispatchMessage(Handler.java:112)
System.err: at android.os.Looper.loop(Looper.java:216)
System.err: at android.app.ActivityThread.main(ActivityThread.java:7625)
System.err: at java.lang.reflect.Method.invoke(Native Method)
System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
System.err: Caused by: com.tns.NativeScriptException: Calling js method onCreate failed
System.err: Error: Can't resolve all parameters for ApplicationModule: (?).
System.err: at com.tns.Runtime.callJSMethodNative(Native Method)
System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1286)
System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:1173)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1160)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1138)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1134)
System.err: at com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:24)
System.err: at android.app.Activity.performCreate(Activity.java:7458)
System.err: at android.app.Activity.performCreate(Activity.java:7448)
System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1286)
System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3409)
System.err: ... 11 more
有关更多信息,以下是我的 package.json:
{
"nativescript": {
"id": "pt.XX.YY",
"tns-ios": {
"version": "6.5.0-2020-05-05-100821-02"
},
"tns-android": {
"version": "6.5.1"
}
},
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"repository": "<fill-your-repository-here>",
"dependencies": {
"@angular/animations": "~9.0.0",
"@angular/common": "~9.0.0",
"@angular/compiler": "~9.0.0",
"@angular/core": "~9.0.0",
"@angular/forms": "~9.0.0",
"@angular/platform-browser": "~9.0.0",
"@angular/platform-browser-dynamic": "~9.0.0",
"@angular/router": "~9.0.0",
"@nativescript/angular": "https://github.com/nstudio/ns-ng/blob/master/nativescript-angular-9.0.0.tgz?raw=true",
"@nativescript/core": "6.6.0-next-2020-05-08-112112-01",
"@nativescript/theme": "^2.3.3",
"@nstudio/nativescript-checkbox": "^1.0.0",
"nativescript-angular": "^8.21.0",
"nativescript-feedback": "^1.3.12",
"nativescript-lottie": "^4.0.1",
"nativescript-material-floatingactionbutton": "^3.2.8",
"nativescript-material-textfield": "^3.2.8",
"nativescript-ngx-shadow": "^6.5.0",
"nativescript-plugin-firebase": "^10.5.2",
"nativescript-statusbar": "^5.0.0",
"nativescript-ui-calendar": "^6.1.0",
"nativescript-ui-listview": "^8.2.0",
"reflect-metadata": "~0.1.12",
"rxjs": "^6.4.0",
"tns-core-modules": "^6.5.8",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular/compiler-cli": "~9.0.0",
"@ngtools/webpack": "~9.0.0",
"nativescript-dev-webpack": "^1.5.1",
"typescript": "~3.6.4"
},
"gitHead": "e9af7b54b243e55ef28e4610c4ef8c83837d86c0",
"readme": "NativeScript Application"
}
此外,如果需要,我的 NgModule 会导入:
@NgModule({
bootstrap: [
AppComponent
],
imports: [
NativeScriptModule,
NativeScriptFormsModule,
NativeScriptRouterModule,
NativeScriptMaterialTextFieldModule,
NativeScriptUIListViewModule,
NativeScriptUICalendarModule,
AppRoutingModule,
TNSCheckBoxModule,
NativeScriptStatusBarModule,
NgShadowModule
],
下面也是我的 tsconfig,我猜它有常春藤“修复”:
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"downlevelIteration": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noEmitHelpers": true,
"noEmitOnError": true,
"skipLibCheck": true,
"lib": [
"es2017",
"es6",
"dom",
"es2015.iterable"
],
"baseUrl": ".",
"paths": {
"~/*": [
"app/*"
],
"*": [
"./node_modules/*"
]
}
},
"angularCompilerOptions": {
"enableIvy": false
},
"includes": [
"references.d.ts"
],
"files": [
"./app/main.ts"
],
"exclude": [
"node_modules",
"platforms",
"**/*.aot",
"e2e"
]
}
任何想法?如果你们需要更多信息,请告诉我。
谢谢
解决方案
好吧,以某种方式运行标志 --env.aot 解决了这个问题。可能会帮助某人:)
推荐阅读
- html - 显示:弹性和无响应的照片 HTML + CSS
- c# - 如何在 C# 中对重复的查询结果进行分组?
- mysql - 从一个表中查找不存在于另一个表中的记录,或者特定值的总和为 0
- javascript - Webpack 错误堆栈未显示在源映射文件中
- git - “致命:不是 git 存储库(或任何父目录):.git”错误,尽管存在 .git 目录
- javascript - 如何放置 2s并排
- python - 在 pandas Series/DataFrame 上执行多个字符串操作
- sas - DM 命令打开 rwork 库中的最后一个数据集
- angular - 映射嵌套在一个 http.get 中的多个 http 请求
- python - 使用切片从随机索引创建邻接矩阵