Error when build with --aot


#1

hello
i got this error when add --aot to run or build

ONSOLE ERROR [native code]: ERROR Error: StaticInjectorError[e -> e]:
StaticInjectorError(Platform: core)[e -> e]:
NullInjectorError: No provider for e!
CONSOLE ERROR [native code]: ERROR CONTEXT {
"view": {
"def": {
"nodeFlags": 33669121,
"rootNodeFlags": 33554433,
"nodeMatchedQueries": 0,
"flags": 0,
"nodes": [
{
"nodeIndex": 0,
"parent": null,
"renderParent": null,
"bindingIndex": 0,
"outputIndex": 0,
"checkIndex": 0,
"flags": 33554433,
"childFlags": 114688,
"directChildFlags": 114688,
"childMatchedQueries": 0,
"matchedQueries": {},
"matchedQueryIds": 0,
"references": {},
"ngContentIndex": null,
"childCount": 1,
"bindings": [],
"bindingFlags": 0,
"outputs": [],
"element": {
"ns": "",
"name": "ns-app",
"attrs": [],
"template": null,
"componentProvider": {
"nodeIndex": 1,
"parent": "[Circular]",
"renderParent": "[Circular]",

CONSOLE ERROR file:///app/vendor.js:1:234209: bootstrap: ERROR BOOTSTRAPPING ANGULAR
CONSOLE ERROR file:///app/vendor.js:1:234209: bootstrap: StaticInjectorError[e -> e]:
StaticInjectorError(Platform: core)[e -> e]:
NullInjectorError: No provider for e!
X@file:///app/vendor.js:1:790075
get@file:///app/vendor.js:1:13935
file:///app/vendor.js:1:16807
we@file:///app/vendor.js:1:16822
get@file:///app/vendor.js:1:15982
file:///app/vendor.js:1:16807
we@file:///app/vendor.js:1:16822
get@file:///app/vendor.js:1:15982
Ii@file:///app/vendor.js:1:89987
Si@file:///app/vendor.js:1:89058
na@file:///app/vendor.js:1:100476
Ji@file:///app/vendor.js:1:99251
Ja@file:///app/vendor.js:1:116909
create@file:///app/vendor.js:1:78998
bootstrap@file:///app/vendor.js:1:44590
forEach@[native code]
_moduleDoBootstrap@file:///app/vendor.js:1:41977
file:///app/vendor.js:1:41612
onInvoke@file:///app/vendor.js:1:35355
run@file:///app/vendor.js:1:777994
file:///app/vendor.js:1:788244
onInvokeTask@file:///app/vendor.js:1:35271
runTask@file:///app/vendor.js:1:778683
w@file:///app/vendor.js:1:786595
file:///app/vendor.

my package json is

{
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "com.lamassu.baghdadmall",
    "tns-android": {
      "version": "4.2.0-2018-06-18-02"
    },
    "tns-ios": {
      "version": "4.1.1"
    }
  },
  "dependencies": {
    "@angular/animations": "~5.2.0",
    "@angular/common": "~5.2.0",
    "@angular/compiler": "~5.2.0",
    "@angular/core": "~5.2.0",
    "@angular/forms": "~5.2.0",
    "@angular/http": "~5.2.0",
    "@angular/platform-browser": "~5.2.0",
    "@angular/platform-browser-dynamic": "~5.2.0",
    "@angular/router": "~5.2.0",
    "nativescript-angular": "~5.3.0",
    "nativescript-app-tour": "^0.9.1",
    "nativescript-barcodescanner": "^2.7.7",
    "nativescript-carousel": "^3.1.1",
    "nativescript-fancyalert": "^1.2.0",
    "nativescript-image-swipe": "^3.0.0",
    "nativescript-image-zoom": "^3.0.0",
    "nativescript-ng2-carousel": "0.0.5",
    "nativescript-ng2-slides": "0.0.11",
    "nativescript-onesignal": "^1.0.7",
    "nativescript-rotate-3d": "^0.8.0",
    "nativescript-theme-core": "~1.0.4",
    "nativescript-ui-sidedrawer": "^4.1.1",
    "reflect-metadata": "~0.1.10",
    "rxjs": "~5.5.5",
    "tns-core-modules": "^4.1.0",
    "tns-platform-declarations": "^4.1.0",
    "zone.js": "~0.8.18"
  },
  "devDependencies": {
    "@angular-devkit/core": "~0.6.3",
    "@angular/compiler-cli": "~5.2.0",
    "@ngtools/webpack": "~6.0.3",
    "babel-traverse": "6.26.0",
    "babel-types": "6.26.0",
    "babylon": "6.18.0",
    "clean-webpack-plugin": "~0.1.19",
    "copy-webpack-plugin": "~4.5.1",
    "css-loader": "~0.28.11",
    "extract-text-webpack-plugin": "~3.0.2",
    "lazy": "1.0.11",
    "nativescript-css-loader": "~0.26.0",
    "nativescript-dev-typescript": "~0.7.0",
    "nativescript-dev-webpack": "^0.12.0",
    "nativescript-worker-loader": "~0.9.0",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.3.0",
    "typescript": "~2.7.2",
    "uglifyjs-webpack-plugin": "~1.2.5",
    "webpack": "~4.6.0",
    "webpack-bundle-analyzer": "~2.13.0",
    "webpack-cli": "~2.1.3",
    "webpack-sources": "~1.1.0"
  },
  "scripts": {
    "ns-bundle": "ns-bundle",
    "publish-ios-bundle": "npm run ns-bundle --ios --publish-app",
    "generate-android-snapshot": "generate-android-snapshot --targetArchs arm,arm64,ia32 --install",
    "start-android-bundle": "npm run ns-bundle --android --run-app",
    "start-ios-bundle": "npm run ns-bundle --ios --run-app",
    "build-android-bundle": "npm run ns-bundle --android --build-app",
    "build-ios-bundle": "npm run ns-bundle --ios --build-app"
  }
}

my main.ts

// this import should be first in order to load some required settings (like globals and reflect-metadata)
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
import { NgModule, enableProdMode } from "@angular/core";
import { AppComponent } from "./app.component";
import { NativeScriptRouterModule, RouterExtensions } from "nativescript-angular/router";
import { appComponents, appRoutes } from "./app.routing";
import { NativeScriptUISideDrawerModule } from "nativescript-ui-sidedrawer/angular";
import { registerElement } from "nativescript-angular/element-registry";
import {CarouselDirective} from "nativescript-ng2-carousel/nativescript-ng2-carousel";
import { BarcodeScanner } from "nativescript-barcodescanner";
import { Api } from "~/api/api";
import { NativeScriptHttpModule, platformNativeScriptDynamic } from "nativescript-angular";
import * as application from 'application';
import { HttpModule } from "@angular/http";
import {HttpClientModule, HttpClient} from '@angular/common/http';


var TnsOneSignal = require('nativescript-onesignal').TnsOneSignal
 

enableProdMode();

application.on(application.resumeEvent, (args) => {
    if (args.android) {
        // For Android applications, args.android is an android activity class.

    } else if (args.ios) {
        // For iOS applications, args.ios is UIApplication.

    }
});




if ( application.ios ) {
            class MyDelegate extends UIResponder implements UIApplicationDelegate {
                public static ObjCProtocols = [UIApplicationDelegate];
                applicationDidFinishLaunchingWithOptions(application: UIApplication, launchOptions: NSDictionary<any, any>): boolean {
                    try {
                        //console.log('TnsOneSignal', TnsOneSignal);
                        TnsOneSignal.initWithLaunchOptionsAppId(launchOptions, '4e2c86a5-b635-4193-8bec-cd5da97261b1');
                    } catch (error) {
                        console.error('error', error);
                    }
                    return true;
                }
                applicationDidBecomeActive(application: UIApplication): void {
                    //console.log("applicationDidBecomeActive: " + application);
                }
            }
            application.ios.delegate = MyDelegate;
        }
if (application.android) {
    application.on(application.launchEvent, function(args: application.ApplicationEventData) {
 
        try {
 
            TnsOneSignal.startInit(application.android.context)
            .setNotificationReceivedHandler(new TnsOneSignal.NotificationReceivedHandler({
                notificationReceived: notification => {
                    console.log(notification.payload.title);
                }
            }))
            .init();
       
 
            
            
        } catch (error) {
            console.error('error', error)
        }
 
    })
} 

registerElement("ImageSwipe", () => require("nativescript-image-swipe/image-swipe").ImageSwipe);
registerElement('ImageZoom', () => require('nativescript-image-zoom').ImageZoom);
registerElement("Rotate3D", () => require("nativescript-rotate-3d").Rotate3D);
registerElement("Carousel", () => require("nativescript-carousel").Carousel);
registerElement("CarouselItem", () => require("nativescript-carousel").CarouselItem);
registerElement("BarcodeScanner", () => require("nativescript-barcodescanner").BarcodeScannerView);


@NgModule({
    



    
    declarations: [AppComponent, ...appComponents,CarouselDirective],
    bootstrap: [AppComponent],
    imports: [
        NativeScriptUISideDrawerModule,
        NativeScriptModule,
        NativeScriptRouterModule,
        NativeScriptHttpModule,
        HttpModule,
        HttpClientModule,
        NativeScriptRouterModule.forRoot(appRoutes)
    ],
    providers: [
        BarcodeScanner,
        Api,
        RouterExtensions,
        
      ]
})
class AppComponentModule {}

platformNativeScriptDynamic().bootstrapModule(AppComponentModule);

#2