NativeScript / nativescript-dev-webpack

A package to help with webpacking NativeScript apps.
Apache License 2.0
97 stars 49 forks source link

Nativescript-dev-webpack --env.aot makes the app crash at startup #608

Closed tsonevn closed 6 years ago

tsonevn commented 6 years ago

From @virtualbjorn on July 10, 2018 23:32

Did you verify this is a real problem by searching the [NativeScript Forum]

Yes

Tell us about the problem

Applied webpacking on an angular project. The app runs fine without --env.aot.

Which platform(s) does your issue occur on?

Both

Please provide the following version numbers that your issue occurs with:

{
  "description": "xxxxxxx",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "xxxxxx",
    "tns-ios": {
      "version": "4.1.1"
    },
    "tns-android": {
      "version": "4.1.3"
    }
  },
  "dependencies": {
    "@angular/animations": "~6.0.0",
    "@angular/common": "~6.0.0",
    "@angular/compiler": "~6.0.0",
    "@angular/core": "~6.0.0",
    "@angular/forms": "~6.0.0",
    "@angular/http": "~6.0.0",
    "@angular/platform-browser": "~6.0.0",
    "@angular/platform-browser-dynamic": "~6.0.0",
    "@angular/router": "~6.0.0",
    "@types/crypto-js": "^3.1.41",
    "crypto-js": "^3.1.9-1",
    "moment": "^2.22.1",
    "nativescript-angular": "^6.0.0",
    "nativescript-camera": "^4.0.2",
    "nativescript-checkbox": "^3.0.3",
    "nativescript-email": "^1.5.3",
    "nativescript-geolocation": "^4.2.6",
    "nativescript-iqkeyboardmanager": "^1.3.0",
    "nativescript-localstorage": "^1.1.5",
    "nativescript-theme-core": "~1.0.4",
    "nativescript-toast": "^1.4.6",
    "reflect-metadata": "~0.1.8",
    "rxjs": "~6.0.0 || >=6.1.0",
    "tns-core-modules": "^4.1.0",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/core": "~0.6.3",
    "@angular/compiler-cli": "~6.0.0",
    "@ngtools/webpack": "~6.0.3",
    "babel-traverse": "6.4.5",
    "babel-types": "6.4.5",
    "babylon": "6.4.5",
    "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-dev-sass": "^1.6.0",
    "nativescript-dev-typescript": "^0.7.0",
    "nativescript-dev-webpack": "^0.12.0",
    "nativescript-worker-loader": "~0.9.0",
    "node-sass": "^4.9.2",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.3.0",
    "sass-loader": "^7.0.3",
    "tns-platform-declarations": "^4.0.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"
  },
  "author": "virtualbjorn"
}

Please tell us how to recreate the issue in as much detail as possible.

Sadly, the app I'm currently building is an enterprise app and I'm not sure if this can be replicated. But here's the error log:

An uncaught Exception occurred on "main" thread.
java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: 

Error calling module function 

Error calling module function 

Error: A platform with a different configuration has been created. Please destroy it first.
File: "file:///data/data/com.sampleapp.sample/files/app/vendor.js, line: 1, column: 51338

StackTrace: 
    Frame: function:'c', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 1667808
    Frame: function:'Bn', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 51345
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 51234
    Frame: function:'t.platformNativeScript', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 1325029
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 313540
    Frame: function:'445', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 313573
    Frame: function:'o', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 589
    Frame: function:'e', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 465
    Frame: function:'module.exports.297', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 1157
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 1161
    Frame: function:'require', file:'', line: 1, column: 266
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/starter.js', line: 2, column: 1
    Frame: function:'require', file:'', line: 1, column: 266

Error: A platform with a different configuration has been created. Please destroy it first.
File: "<unknown>, line: 1, column: 265

StackTrace: 
    Frame: function:'c', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 1667808
    Frame: function:'Bn', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 51345
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 51234
    Frame: function:'t.platformNativeScript', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 1325029
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 313540
    Frame: function:'445', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 313573
    Frame: function:'o', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 589
    Frame: function:'e', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 465
    Frame: function:'module.exports.297', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 1157
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 1161
    Frame: function:'require', file:'', line: 1, column: 266
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/starter.js', line: 2, column: 1
    Frame: function:'require', file:'', line: 1, column: 266

Error: A platform with a different configuration has been created. Please destroy it first.
File: "<unknown>, line: 1, column: 265

StackTrace: 
    Frame: function:'c', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 1667808
    Frame: function:'Bn', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 51345
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 51234
    Frame: function:'t.platformNativeScript', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 1325029
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 313540
    Frame: function:'445', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 313573
    Frame: function:'o', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 589
    Frame: function:'e', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 465
    Frame: function:'module.exports.297', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 1157
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 1161
    Frame: function:'require', file:'', line: 1, column: 266
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/starter.js', line: 2, column: 1
    Frame: function:'require', file:'', line: 1, column: 266

    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5406)
    at android.app.ActivityThread.-wrap2(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1545)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6119)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
Caused by: com.tns.NativeScriptException: 

Error calling module function 

Error calling module function 

Error: A platform with a different configuration has been created. Please destroy it first.
File: "file:///data/data/com.sampleapp.sample/files/app/vendor.js, line: 1, column: 51338

StackTrace: 
    Frame: function:'c', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 1667808
    Frame: function:'Bn', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 51345
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 51234
    Frame: function:'t.platformNativeScript', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 1325029
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 313540
    Frame: function:'445', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 313573
    Frame: function:'o', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 589
    Frame: function:'e', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 465
    Frame: function:'module.exports.297', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 1157
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 1161
    Frame: function:'require', file:'', line: 1, column: 266
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/starter.js', line: 2, column: 1
    Frame: function:'require', file:'', line: 1, column: 266

Error: A platform with a different configuration has been created. Please destroy it first.
File: "<unknown>, line: 1, column: 265

StackTrace: 
    Frame: function:'c', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 1667808
    Frame: function:'Bn', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 51345
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 51234
    Frame: function:'t.platformNativeScript', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 1325029
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 313540
    Frame: function:'445', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 313573
    Frame: function:'o', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 589
    Frame: function:'e', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 465
    Frame: function:'module.exports.297', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 1157
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 1161
    Frame: function:'require', file:'', line: 1, column: 266
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/starter.js', line: 2, column: 1
    Frame: function:'require', file:'', line: 1, column: 266

Error: A platform with a different configuration has been created. Please destroy it first.
File: "<unknown>, line: 1, column: 265

StackTrace: 
    Frame: function:'c', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 1667808
    Frame: function:'Bn', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 51345
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 51234
    Frame: function:'t.platformNativeScript', file:'file:///data/data/com.sampleapp.sample/files/app/vendor.js', line: 1, column: 1325029
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 313540
    Frame: function:'445', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 313573
    Frame: function:'o', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 589
    Frame: function:'e', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 465
    Frame: function:'module.exports.297', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 1157
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/bundle.js', line: 1, column: 1161
    Frame: function:'require', file:'', line: 1, column: 266
    Frame: function:'', file:'file:///data/data/com.sampleapp.sample/files/app/starter.js', line: 2, column: 1
    Frame: function:'require', file:'', line: 1, column: 266

    at com.tns.Runtime.runModule(Native Method)
    at com.tns.Runtime.runModule(Runtime.java:542)
    at com.tns.Runtime.run(Runtime.java:534)
    at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:21)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1024)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5403)
    ... 8 more

Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.

Copied from original issue: NativeScript/NativeScript#6052

NickIliev commented 6 years ago

@virtualbjorn can you try to update yo the latest nativescript-dev-webpack and nativescript-angular. Then with removed platforms folder you can rebuild the project with AOT and let us know if the build is successful.

Upgrade instructions via automated scripts can be found in this documentation section

virtualbjorn commented 6 years ago

@NickIliev I updated and tried using the latest nativescript-dev-webpack and nativescript-angular but still the same error.