我正在尝试在Android上构建NativeScript应用。该应用程序编译时没有错误,但是当我尝试在模拟器中进行构建时,出现以下错误:
“错误:缺少主条目。无法启动应用程序。请验证应用程序引导程序。”
我们已经尝试删除node_modules和package-lock.json并运行yarn / npm install,但似乎没有任何作用。
这是我的package.json的样子:
{
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"readme": "NativeScript Application",
"repository": "<fill-your-repository-here>",
"nativescript": {
"id": "*****",
"tns-android": {
"version": "5.4.0"
}
},
"dependencies": {
"@angular/animations": "^7.2.15",
"@angular/common": "^7.2.15",
"@angular/compiler": "^7.2.15",
"@angular/core": "^7.2.15",
"@angular/forms": "^7.2.15",
"@angular/http": "^7.2.15",
"@angular/platform-browser": "^7.2.15",
"@angular/platform-browser-dynamic": "^7.2.15",
"@angular/router": "^7.2.15",
"@firebase/app": "^0.1.7",
"angular": "^1.7.2",
"angularfire2": "^5.0.0-rc.6",
"copy-webpack-plugin": "^5.0.3",
"cross-spawn": "^5.1.0",
"firebase": "^6.1.0",
"http-signature": "^1.2.0",
"moment": "^2.20.1",
"nativescript-angular": "^7.2.4",
"nativescript-directions": "^1.1.2",
"nativescript-email": "^1.5.1",
"nativescript-material-icons": "^1.0.3",
"nativescript-ng2-fonticon": "^1.3.4",
"nativescript-plugin-firebase": "^8.3.2",
"nativescript-theme-core": "^1.0.4",
"npmlog": "^4.1.2",
"reflect-metadata": "~0.1.8",
"request": "^2.88.0",
"rxjs": "^6.3.3",
"rxjs-compat": "^6.5.2",
"string-similarity": "^1.2.0",
"tns-core-modules": "^5.4.2",
"webpack": "^4.33.0",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/cli": "^7.3.9",
"@angular/compiler-cli": "8.0.0",
"@ngtools/webpack": "8.0.0",
"babel-core": "^6.26.3",
"babel-loader": "^7.1.1",
"babel-traverse": "^6.26.0",
"babel-types": "^6.26.0",
"babylon": "6.4.5",
"extract-text-webpack-plugin": "~3.0.0",
"lazy": "1.0.11",
"nativescript-dev-sass": "^1.2.0",
"nativescript-dev-typescript": "^0.10.0",
"nativescript-dev-webpack": "^0.24.1",
"node-sass": "^4.5.3",
"typescript": "^3.1.4",
"uglifyjs-webpack-plugin": "~1.1.6",
"webpack-cli": "^3.3.3"
}
}
这是整个堆栈跟踪:
An uncaught Exception occurred on "main" thread.
java.lang.RuntimeException: Unable to start activity ComponentInfo{*****/com.tns.NativeScriptActivity}: com.tns.NativeScriptException:
Calling js method onCreate failed
Error: Main entry is missing. App cannot be started. Verify app bootstrap.
File: "file:///data/data/*****/files/app/vendor.js, line: 21779, column: 20
StackTrace:
Frame: function:'push.../node_modules/tns-core-modules/ui/frame/frame.js.ActivityCallbacksImplementation.setActivityContent', file:'file:///data/data/*****/files/app/vendor.js', line: 21779, column: 27
Frame: function:'push.../node_modules/tns-core-modules/ui/frame/frame.js.ActivityCallbacksImplementation.onCreate', file:'file:///data/data/*****/files/app/vendor.js', line: 21624, column: 14
Frame: function:'push.../node_modules/tns-core-modules/ui/frame/activity.js.NativeScriptActivity.onCreate', file:'file:///data/data/*****/files/app/vendor.js', line: 19438, column: 25
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: com.tns.NativeScriptException:
Calling js method onCreate failed
Error: Main entry is missing. App cannot be started. Verify app bootstrap.
File: "file:///data/data/*****/files/app/vendor.js, line: 21779, column: 20
StackTrace:
Frame: function:'push.../node_modules/tns-core-modules/ui/frame/frame.js.ActivityCallbacksImplementation.setActivityContent', file:'file:///data/data/*****/files/app/vendor.js', line: 21779, column: 27
Frame: function:'push.../node_modules/tns-core-modules/ui/frame/frame.js.ActivityCallbacksImplementation.onCreate', file:'file:///data/data/*****/files/app/vendor.js', line: 21624, column: 14
Frame: function:'push.../node_modules/tns-core-modules/ui/frame/activity.js.NativeScriptActivity.onCreate', file:'file:///data/data/*****/files/app/vendor.js', line: 19438, column: 25
at com.tns.Runtime.callJSMethodNative(Native Method)
at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1203)
at com.tns.Runtime.callJSMethodImpl(Runtime.java:1083)
at com.tns.Runtime.callJSMethod(Runtime.java:1070)
at com.tns.Runtime.callJSMethod(Runtime.java:1050)
at com.tns.Runtime.callJSMethod(Runtime.java:1042)
at com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:19)
at android.app.Activity.performCreate(Activity.java:7009)
at android.app.Activity.performCreate(Activity.java:7000)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
... 9 more
答案 0 :(得分:0)
将此示例代码添加到main.ts
文件中。
import { platformNativeScriptDynamic } from "nativescript-angular/platform";
import { enableProdMode } from '@angular/core';
import { AppModule } from "./app/app.module";
enableProdMode();
platformNativeScriptDynamic().bootstrapModule(AppModule);