Skip to content

System.err: Calling js method onCreate failed - System.err: Error: Main entry is missing. App cannot be started. Verify app bootstrap #4801

Closed

Description

@Karabillie

Environment

{
  "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"
    }
  }
}

Describe the bug

I have a web application using Angular version 7 and decided to migrate it into a mobile application using NativeScript. After installing successfully nativescript and the schemantics plugins, I tried to run tns run android --bundle on an Android Emulator(Nexus 4 API 8), but I am getting the following error:

System.err: java.lang.RuntimeException: Unable to start activity ComponentInfo{org.nativescript.ngsample/com.tns.NativeScriptActivity}: com.tns.NativeScriptException:
System.err: Calling js method onCreate failed
System.err:
System.err: Error: Main entry is missing. App cannot be started. Verify app bootstrap.
System.err: File: "file:///data/data/org.nativescript.ngsample/files/app/vendor.js, line: 21913, column: 20
System.err:
System.err: StackTrace:
System.err: Frame: function:'push.../node_modules/tns-core-modules/ui/frame/frame.js.ActivityCallbacksImplementation.setActivityContent', file:'file:///data/data/org.nativescript.ngsample/files/app/vendor.js', line: 21913, column: 27
System.err: Frame: function:'push.../node_modules/tns-core-modules/ui/frame/frame.js.ActivityCallbacksImplementation.onCreate', file:'file:///data/data/org.nativescript.ngsample/files/app/vendor.js', line:
21758, column: 14
System.err: Frame: function:'push.../node_modules/tns-core-modules/ui/frame/activity.js.NativeScriptActivity.onCreate', file:'file:///data/data/org.nativescript.ngsample/files/app/vendor.js', line: 19571, column: 25
System.err:
System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2913)
System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3048)
System.err: at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
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:1808)
System.err: at android.os.Handler.dispatchMessage(Handler.java:106)
System.err: at android.os.Looper.loop(Looper.java:193)
System.err: at android.app.ActivityThread.main(ActivityThread.java:6669)
System.err: at java.lang.reflect.Method.invoke(Native Method)
System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
System.err: Caused by: com.tns.NativeScriptException:
System.err: Calling js method onCreate failed
System.err:
System.err: Error: Main entry is missing. App cannot be started. Verify app bootstrap.
System.err: File: "file:///data/data/org.nativescript.ngsample/files/app/vendor.js, line: 21913, column: 20
System.err:
System.err: StackTrace:
System.err: Frame: function:'push.../node_modules/tns-core-modules/ui/frame/frame.js.ActivityCallbacksImplementation.setActivityContent', file:'file:///data/data/org.nativescript.ngsample/files/app/vendor.js', line: 21913, column: 27
System.err: Frame: function:'push.../node_modules/tns-core-modules/ui/frame/frame.js.ActivityCallbacksImplementation.onCreate', file:'file:///data/data/org.nativescript.ngsample/files/app/vendor.js', line:
21758, column: 14
System.err: Frame: function:'push.../node_modules/tns-core-modules/ui/frame/activity.js.NativeScriptActivity.onCreate', file:'file:///data/data/org.nativescript.ngsample/files/app/vendor.js', line: 19571, column: 25
System.err:
System.err: at com.tns.Runtime.callJSMethodNative(Native Method)
System.err: at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1203)
System.err: at com.tns.Runtime.callJSMethodImpl(Runtime.java:1083)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1070)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1050)
System.err: at com.tns.Runtime.callJSMethod(Runtime.java:1042)
System.err: at com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:19)
System.err: at android.app.Activity.performCreate(Activity.java:7136)
System.err: at android.app.Activity.performCreate(Activity.java:7127)
System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1271)
System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2893)
System.err: ... 11 more

To Reproduce
tns run android --bundle

Expected behavior
Application should be executed successfully and show the auto-generated code.

I cannot upload the whole application, as my client does not allow me but if some parts of the application are needed, please let me know to share them.

Activity

  1. Karabillie commented on Jul 3, 2019

    @Karabillie
    Author

    The STRANGEST of all is that when I run the application for the first time, it shows the error. When I change smt and then save it with hot reloading feature, it is shown perfectly.

  2. eweb9ja commented on Jul 20, 2019

    @eweb9ja

    Hi, i m have same issue here, i think is bug from the new release/update
    any help please?

  3. eweb9ja commented on Jul 20, 2019

    @eweb9ja

    hi, Karabillie
    i hope you have to solve the problem?
    "System.err: Error: Main entry is missing. App cannot be started. Verify app bootstrap."

    if not; this is how i solve it:
    i think the problem is coming from the lazy_route_resource, and maybe other module was loaded up before AppModule, as a result, blocking it to load/bootstrap.

    • so i use normal routing
      *and i created a center shared Module to load all the modules; instead of adding the other Components to the AppModule and it works

    i hope this will help you and others who are having this same issue after updating or migrating

  4. Karabillie commented on Jul 21, 2019

    @Karabillie
    Author

    Hi. Thanks for the reply. Unfortunately, it does not work. Can you provide your code sample of this solution? Thanks.

  5. ParthMaisheri commented on Jul 22, 2019

    @ParthMaisheri

    Hi. Thanks for the reply. Unfortunately, it does not work. Can you provide your code sample of this solution? Thanks.

    having similar issue after migrating to 6.0.0 (on Android).

  6. eweb9ja commented on Jul 22, 2019

    @eweb9ja

    Please NOTE the COMMENT Section:

    AppModule:
    /////////////////////////////////////////////////////////////////////////////////////////////////

    import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
    import { NativeScriptModule } from "nativescript-angular/nativescript.module";
    import { NativeScriptUISideDrawerModule } from "nativescript-ui-sidedrawer/angular";

    import { AppRoutingModule } from "./app-routing.module";
    import { AppComponent } from "./app.component";

    // Center SharedModules ("SharedModulesModule") that connect other modules/shared-modules
    // With this, you can avoid over loading the AppModule; therefor allowing the AppModule run first

    import { SharedModulesModule } from './shared-modules/shared-modules.module';

    @NgModule({
    bootstrap: [
    AppComponent
    ],
    imports: [
    AppRoutingModule,
    NativeScriptModule,
    NativeScriptUISideDrawerModule,
    SharedModulesModule
    ],
    declarations: [
    AppComponent
    ],
    schemas: [
    NO_ERRORS_SCHEMA
    ]
    })
    export class AppModule { }

    App-Route.Module:
    /////////////////////////////////////////////////////////////////////////////////////////////////

    import { NgModule } from "@angular/core";
    import { Routes } from "@angular/router";
    import { NativeScriptRouterModule } from "nativescript-angular/router";

    import { WelcomeComponent } from './welcome/welcome.component';
    import { ChatRoomComponent } from './chat-room/chat-room.component';
    import { LoginComponent } from "./login/login.component";

    const routes: Routes = [

    // Make sure you run the redirectTo using a non-lazy router
    // i guess the lazy route loads the Other Modules before the AppModule
    
    { path: "", redirectTo: "/welcome", pathMatch: "full" },
    { path: 'welcome', component: WelcomeComponent },
    
    // These are the lazy_route from default SideDrawer installations
    
    { path: "home", loadChildren: "~/app/home/home.module#HomeModule" },
    { path: "browse", loadChildren: "~/app/browse/browse.module#BrowseModule" },
    { path: "search", loadChildren: "~/app/search/search.module#SearchModule" },
    { path: "featured", loadChildren: "~/app/featured/featured.module#FeaturedModule" },
    { path: "settings", loadChildren: "~/app/settings/settings.module#SettingsModule" },
    
    // The non-lazy route Component
    
    { path: 'chatroom', component: ChatRoomComponent },
    { path: "login", component: LoginComponent },
    

    ];

    @NgModule({
    imports: [NativeScriptRouterModule.forRoot(routes)],
    exports: [NativeScriptRouterModule]
    })
    export class AppRoutingModule { }

    SharedModulesModule:
    /////////////////////////////////////////////////////////////////////////////////////////////////

    import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
    import { CommonModule } from '@angular/common';
    import { NativeScriptCommonModule } from "nativescript-angular/common";
    import { HttpClientModule } from "@angular/common/http";

    // Center SharedModules ("SharedModulesModule") that connect other modules/shared-modules

    import { ChatRoomComponent } from '../chat-room/chat-room.component';
    import { WelcomeComponent } from '../welcome/welcome.component';
    import { LoginComponent } from "../login/login.component";

    @NgModule({
    imports: [
    CommonModule, NativeScriptCommonModule,
    HttpClientModule
    ],
    declarations: [
    ChatRoomComponent,
    WelcomeComponent,
    LoginComponent

    ],
    providers: [
    // LoginService,

    ],
    schemas: [
    NO_ERRORS_SCHEMA
    ]

    })
    export class SharedModulesModule { }

  7. eweb9ja commented on Jul 23, 2019

    @eweb9ja

    Also from this Error lines:
    System.err: Frame: function:'push.../node_modules/tns-core-modules/ui/frame...

    Make sure you add "tns-core-modules" to some of your imports:
    e.g:
    import { topmost } from "tns-core-modules/ui/frame";
    import { Page } from "tns-core-modules/ui/page";
    import { screen } from "tns-core-modules/platform";
    import * as app from "tns-core-modules/application";
    import { Color } from "tns-core-modules/color";
    etc

  8. Fatme commented on Jul 24, 2019

    @Fatme
    Contributor

    @Karabillie,

    Angular CLI has a strict requirement for the version of typescript, meaning if your typescript version is not in the supported range, an error will be thrown and no javascript files will be produced. However, NativeScript CLI will not stop the command execution on this error and the application will be installed on device. When trying to start the application on device, an error will be thrown due to the missing javascript files.

    In order to check if this is the case with your project, can you please ensure that no errors are shown from webpack compilation - just scroll in your terminal till the beginning of the command and check for red messages.

  9. ParthMaisheri commented on Jul 25, 2019

    @ParthMaisheri

    I restarted migration again with a backup and it works well.

  10. eweb9ja commented on Jul 25, 2019

    @eweb9ja

    @ParthMaisheri
    good to hear that, wish you the best !

  11. eweb9ja commented on Jul 25, 2019

    @eweb9ja

    @Karabillie
    what is the progress now ? i hope you have sort it out?

  12. Karabillie commented on Jul 26, 2019

    @Karabillie
    Author

    @Fatme Hi! Sorry for the late reply. I also migrated to new new version of NativeScript but nothing changed. The only strange error that I am getting is:

    ERROR in e2e/app.e2e-spec.ts(12,45): error TS2345: Argument of type '"Welcome to app!!"' is not assignable to parameter of type 'Expected<Promise>'.

    For typescript version, I changed from ^3.4.5 to ~3.4.5.

  13. Karabillie commented on Jul 26, 2019

    @Karabillie
    Author

    @eweb9ja Hi! Sorry for the late reply. Your solution did not work for me :/

  14. self-assigned this
    on Jul 29, 2019
  15. Fatme commented on Jul 30, 2019

    @Fatme
    Contributor

    @Karabillie,

    It seems that no .js files are emitted due to the error you mention.

    ERROR in e2e/app.e2e-spec.ts(12,45): error TS2345: Argument of type '"Welcome to app!!"' is not assignable to parameter of type 'Expected'.

    This is expecting to happen when noEmitOnError: true is set in your tsconfig.json file.
    We're trying to set it to false - noEmitOnError: false and expecting that .js files will be emitted and this will resolve the issue. However, this didn't help us and still no.js files were emitted.

    After investigating the issue, we found that the problem is in AngularCompilerPlugin and the way it handles typescript's compiler errors and options. We opened a PR in angular-cli repo fixing the described behavior - angular/angular-cli#15199.

    Meanwhile, you can fix your compilation error in e2e/app.e2e-spec.ts file in order to workaround this issue.

  16. DimitarTachev commented on Aug 8, 2019

    @DimitarTachev
    Contributor

    Hi @Karabillie,

    I'm closing the issue as we've isolated the problem and the issue with not pausing on Webpack errors is already logged.

  17. job111 commented on Aug 10, 2019

    @job111

    I'm facing the same issue and none of the suggestions above seems to be working

  18. DimitarTachev commented on Aug 12, 2019

    @DimitarTachev
    Contributor

    @job111, please open a new issue following the issue template and providing the required versions and logs in order to allow us to investigate it further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions