System.err:调用js方法onCreate失败-System.err:错误:缺少主条目。应用无法启动。验证应用引导程序

时间:2019-07-03 12:31:43

标签: android nativescript webpack-dev-server nativescript-angular code-sharing

我有一个使用Angular版本7的Web应用程序,并且想要从NativeScript进行代码共享。 成功安装本机脚本和模式后,我尝试运行tns run android --bundle。

最糟糕的是,当我第一次运行该应用程序时,它显示了错误。当我更改smt,然后使用热重载功能将其保存时,它会完美显示。

但是我收到此错误:

  

System.err:java.lang.RuntimeException:无法启动活动   ComponentInfo {org.nativescript.ngsample / com.tns.NativeScriptActivity}:   com.tns.NativeScriptException:System.err:调用js方法onCreate   失败的System.err:System.err:错误:缺少主条目。应用程式   无法启动。验证应用程序引导程序。 System.err:文件:   “ file:///data/data/org.nativescript.ngsample/files/app/vendor.js,   行:21913,列:20 System.err:System.err:StackTrace:   System.err:框架:   函数:'推... / node_modules / tns-core-modules / ui / frame / frame.js.ActivityCallbacksImplementation.setActivityContent',   文件:“ file:///data/data/org.nativescript.ngsample/files/app/vendor.js”,   行:21913,列:27 System.err:框架:   函数:'推... / node_modules / tns-core-modules / ui / frame / frame.js.ActivityCallbacksImplementation.onCreate',   文件:“ file:///data/data/org.nativescript.ngsample/files/app/vendor.js”,   行:21758,列:14 System.err:框架:   函数:'推... / node_modules / tns-core-modules / ui / frame / activity.js.NativeScriptActivity.onCreate',   文件:“ file:///data/data/org.nativescript.ngsample/files/app/vendor.js”,   行:19571,列:25 System.err:System.err:在   android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)   System.err:位于   android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)   System.err:位于   android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)   System.err:位于   android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)   System.err:位于   android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)   System.err:位于   android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1808)   System.err:位于   android.os.Handler.dispatchMessage(Handler.java:106)System.err:
  在android.os.Looper.loop(Looper.java:193)System.err:at   android.app.ActivityThread.main(ActivityThread.java:6669)System.err:   在java.lang.reflect.Method.invoke(本机方法)System.err:在   com.android.internal.os.RuntimeInit $ MethodAndArgsCaller.run(RuntimeInit.java:493)   System.err:位于   com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)   System.err:由:com.tns.NativeScriptException:System.err:   调用js方法onCreate失败System.err:System.err:错误:Main   条目丢失。应用无法启动。验证应用程序引导程序。   System.err:文件:   “ file:///data/data/org.nativescript.ngsample/files/app/vendor.js,   行:21913,列:20 System.err:System.err:StackTrace:   System.err:框架:   函数:'推... / node_modules / tns-core-modules / ui / frame / frame.js.ActivityCallbacksImplementation.setActivityContent',   文件:“ file:///data/data/org.nativescript.ngsample/files/app/vendor.js”,   行:21913,列:27 System.err:框架:   函数:'推... / node_modules / tns-core-modules / ui / frame / frame.js.ActivityCallbacksImplementation.onCreate',   文件:“ file:///data/data/org.nativescript.ngsample/files/app/vendor.js”,   行:21758,列:14 System.err:框架:   函数:'推... / node_modules / tns-core-modules / ui / frame / activity.js.NativeScriptActivity.onCreate',   文件:“ file:///data/data/org.nativescript.ngsample/files/app/vendor.js”,   行:19571,列:25 System.err:System.err:在   com.tns.Runtime.callJSMethodNative(本机方法)System.err:在   com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1203)   System.err:位于com.tns.Runtime.callJSMethodImpl(Runtime.java:1083)   System.err:位于com.tns.Runtime.callJSMethod(Runtime.java:1070)   System.err:位于com.tns.Runtime.callJSMethod(Runtime.java:1050)   System.err:位于com.tns.Runtime.callJSMethod(Runtime.java:1042)   System.err:位于   com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:19)   System.err:位于   android.app.Activity.performCreate(Activity.java:7136)System.err:
  在android.app.Activity.performCreate(Activity.java:7127)System.err处:   在   android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)   System.err:位于   android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)   System.err:... ...还有11个成功同步的应用程序   设备模拟器5554上的org.nativescript.ngsample。

我删除了钩子,平台,node_modules和webpack.config.js文件,然后再次安装,但没有任何更改。我还将tns-core-modules,typescript和nativescript-dev-webpack升级到最新版本。我想念什么?

我的package.json文件:

{
  "name": "farm-management-ui",
  "description": "The UI for farm management",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "android": "tns run android --bundle",
    "ios": "tns run ios --bundle",
    "mobile": "tns run --bundle",
    "preview": "tns preview --bundle",
    "ng": "ng",
    "start": "ng serve --base-href=/ui/",
    "start-local-prod": "ng serve --base-href=/ui/",
    "start-traci": "ng serve --configuration=traci-dev --base-href=/ui/",
    "build": "ng build --prod --base-href=/ui/",
    "build-traci": "ng build --prod --configuration=traci --base-href=/ui/",
    "test": "ng test --code-coverage=true",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "loco": "node tools/update-localized-strings.js",
    "bundle-report": "webpack-bundle-analyzer dist/stats.json",
    "licenses": "node tools/extract-licenses.js"
  },
  "private": true,
  "dependencies": {
    "@angular-devkit/architect": "^0.13.9",
    "@angular-devkit/build-optimizer": "^0.13.9",
    "@angular-devkit/build-webpack": "^0.13.9",
    "@angular-devkit/core": "^7.3.9",
    "@angular/animations": "^7.2.0",
    "@angular/cdk": "^7.2.1",
    "@angular/common": "7.2.0",
    "@angular/compiler": "7.2.0",
    "@angular/core": "7.2.0",
    "@angular/forms": "7.2.0",
    "@angular/http": "7.2.0",
    "@angular/material": "^7.2.1",
    "@angular/platform-browser": "7.2.0",
    "@angular/platform-browser-dynamic": "7.2.0",
    "@angular/router": "7.2.0",
    "@asymmetrik/ngx-leaflet": "^3.0.2",
    "@asymmetrik/ngx-leaflet-draw": "^2.7.1",
    "@asymmetrik/ngx-leaflet-markercluster": "^1.0.0",
    "@bwc/bwc-button": "^2.0.5",
    "@bwc/bwc-footer": "^2.0.2",
    "@bwc/bwc-header": "^4.1.2",
    "@bwc/bwc-input": "^2.2.2",
    "@bwc/bwc-overlay": "^3.0.6",
    "@bwc/bwc-style": "^2.1.0",
    "@inst-iot/bosch-angular-ui-components": "^0.3.20",
    "@nativescript/schematics": "^0.6.0",
    "@ng-bootstrap/ng-bootstrap": "^4.0.1",
    "@ngx-translate/core": "^11.0.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "@schematics/angular": "^7.3.9",
    "@swimlane/ngx-datatable": "^14.0.0",
    "@types/geojson": "^1.0.6",
    "@types/leaflet": "^1.2.6",
    "@types/leaflet.markercluster": "^1.0.3",
    "@types/leaflet.pm": "^0.13.3",
    "@webcomponents/webcomponentsjs": "^2.2.4",
    "angular-2-local-storage": "^1.0.1",
    "bootstrap-daterangepicker": "^3.0.3",
    "bosch-bootstrap": "git+https://products.bosch-si.com/stash/scm/instiot/bosch-bootstrap.git#v4",
    "brace": "^0.10.0",
    "chart.js": "^2.7.2",
    "chartjs-plugin-annotation": "^0.5.7",
    "chartjs-plugin-zoom": "^0.6.6",
    "classlist.js": "^1.1.20150312",
    "core-js": "^2.5.1",
    "file-saver": "^1.3.8",
    "flatpickr": "^4.5.7",
    "font-awesome": "^4.7.0",
    "jquery": "^3.3.1",
    "json-formatter-js": "^2.2.0",
    "leaflet": "^1.3.1",
    "leaflet-draw": "^1.0.2",
    "leaflet-easybutton": "^2.3.0",
    "leaflet.markercluster": "^1.3.0",
    "leaflet.pm": "^0.22.0",
    "magic-string": "^0.22.4",
    "moment": "^2.19.4",
    "nan": "^2.14.0",
    "nativescript-angular": "~7.2.0",
    "nativescript-theme-core": "~1.0.4",
    "ng2-ace-editor": "^0.3.3",
    "ng5-slider": "^1.1.3",
    "ngx-clipboard": "^12.1.2",
    "ngx-gallery": "^4.3.0",
    "ngx-toastr": "^10.0.2",
    "ngx-ui-switch": "^6.0.3",
    "popper.js": "^1.13.0",
    "puppeteer": "^1.17.0",
    "reflect-metadata": "~0.1.12",
    "rxjs": "^6.3.3",
    "sass-loader": "^6.0.5",
    "tmp": "0.0.30",
    "tns-core-modules": "^5.4.3",
    "tslib": "^1.9.0",
    "uuid": "^3.3.2",
    "web-animations-js": "^2.3.1",
    "zone.js": "^0.8.27"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.12.4",
    "@angular/cli": "^7.3.9",
    "@angular/compiler-cli": "8.0.0",
    "@angular/language-service": "7.2.0",
    "@nativescript/schematics": "0.6.0",
    "@types/chart.js": "^2.7.18",
    "@types/jasmine": "2.8.6",
    "@types/leaflet-draw": "^0.4.11",
    "@types/node": "^6.0.92",
    "codelyzer": "^4.2.1",
    "https-proxy-agent": "^2.1.1",
    "jasmine-core": "^2.99.1",
    "jasmine-spec-reporter": "~4.1.0",
    "karma": "^1.7.1",
    "karma-chrome-launcher": "^2.1.1",
    "karma-cli": "~1.0.1",
    "karma-coverage-istanbul-reporter": "^1.4.3",
    "karma-firefox-launcher": "^1.0.1",
    "karma-jasmine": "^1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-spec-reporter": "0.0.32",
    "license-checker": "^21.0.0",
    "nativescript-dev-webpack": "^0.24.1",
    "node-sass": "^4.12.0",
    "protractor": "~5.1.2",
    "rxjs-tslint": "^0.1.6",
    "style-loader": "^0.23.1",
    "ts-node": "~3.0.4",
    "tslint": "^5.10.0",
    "typescript": "^3.4.5"
  },
  "nativescript": {
    "id": "org.nativescript.ngsample",
    "tns-android": {
      "version": "5.4.0"
    }
  }
}

我的main.tns.ts逃跑:

import { platformNativeScriptDynamic } from 'nativescript-angular/platform';

import { AppModule } from './app/app.module';

platformNativeScriptDynamic().bootstrapModule(AppModule);

我的main.ts文件:

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';

if (environment.production) {
  enableProdMode();
}

document.addEventListener('WebComponentsReady', () => {
  platformBrowserDynamic()
    .bootstrapModule(AppModule, {preserveWhitespaces: false})
    .catch(err => console.log(err));
});

2 个答案:

答案 0 :(得分:0)

尝试实现如下所示的引导程序。 main.ts文件

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';

if (environment.production) {
  enableProdMode();
}


platformBrowserDynamic().bootstrapModule(AppModule, {preserveWhitespaces: false})
  .catch(err => console.log(err));

答案 1 :(得分:0)

这对我有用...

  • 从package.json文件中的依赖项和devDependencies中删除所有软件包(仅将其保存在某些.txt文件中,这是必需的)

  • 运行npm i,它将从node_modules文件夹中删除所有软件包

  • 之后,返回所有依赖包和devDependecies中的包,并保存

  • 然后在启动项目后再次运行npm i。