Webpack and Android build


#1

Running my app with:
tns run android

runs fine but when trying to build it with:
tns build android --release --key-store-path /Users/alexsouza/Documents/Personal/Certificates/asouza.jks --key-store-password xxx --key-store-alias xxx --key-store-alias-password xxx --compileSdk 21/22/23/24/25/26/27

I get the following error:

*** nativescript-dev-android-snapshot will be deprecated in the near future in favour of nativescript-dev-webpack plugin. To learn more on how to setup Webpack bundling with V8 heap snapshot generation using nativescript-dev-webpack, read the following article: https://docs.nativescript.org/tooling/bundling-with-webpack  ***

Invalid filename

Any idea how to fix that? Below my package.json file content:

{
  "description": "NativeScript Application",
  "license": "SEE LICENSE IN <your-license-filename>",
  "readme": "NativeScript Application",
  "repository": "<fill-your-repository-here>",
  "nativescript": {
    "id": "com.asouza.ppgFinder",
    "tns-android": {
      "version": "3.4.0"
    },
    "tns-ios": {
      "version": "3.4.0"
    }
  },
  "dependencies": {
    "nativescript-appversion": "^1.4.1",
    "nativescript-directions": "^1.1.0",
    "nativescript-dom": "^2.0.0",
    "nativescript-email": "^1.5.1",
    "nativescript-feedback": "^1.0.6",
    "nativescript-geolocation": "^4.2.1",
    "nativescript-i18n": "^0.2.4",
    "nativescript-imagepicker": "^3.0.1",
    "nativescript-insomnia": "^1.2.1",
    "nativescript-loading-indicator": "^2.4.0",
    "nativescript-mapbox": "^3.1.2",
    "nativescript-permissions": "^1.2.3",
    "nativescript-plugin-firebase": "^5.0.5",
    "nativescript-pro-ui": "^3.3.0",
    "nativescript-screenshot": "0.0.2",
    "nativescript-social-share": "^1.4.0",
    "nativescript-statusbar": "^3.0.1",
    "nativescript-texttospeech": "^2.0.1",
    "nativescript-theme-core": "~1.0.2",
    "tns-core-modules": "^3.4.0",
    "tns-core-modules-snapshot": "3.0.1-5.5.372.32"
  },
  "devDependencies": {
    "babel-traverse": "6.24.1",
    "babel-types": "6.24.1",
    "babylon": "6.17.2",
    "copy-webpack-plugin": "~4.0.1",
    "css-loader": "~0.28.7",
    "extract-text-webpack-plugin": "~3.0.0",
    "lazy": "1.0.11",
    "nativescript-custom-entitlements": "^0.2.0",
    "nativescript-dev-android-snapshot": "^0.*.*",
    "nativescript-dev-webpack": "^0.9.0",
    "nativescript-worker-loader": "~0.8.1",
    "raw-loader": "~0.5.1",
    "resolve-url-loader": "~2.1.0",
    "webpack": "~3.8.1",
    "webpack-bundle-analyzer": "^2.8.2",
    "webpack-sources": "~1.0.1"
  },
  "name": "ppgFinder"
}

Running with “bundle”:
tns run android --bundle

Gives LOTS of errors while executing:

System.err: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.asouza.ppgFinder/com.tns.NativeScriptActivity}: com.tns.NativeScriptException: 
System.err: Calling js method onCreate failed
System.err: 
System.err: Error: Building UI from XML. @file:///app/main-page.xml:17:5
System.err:  > Module '/data/data/com.asouza.ppgFinder/files/app/nativescript-statusbar' not found for element 'nativescript-statusbar:StatusBar'.
System.err:    > com.tns.NativeScriptException: Failed to find module: "/data/data/com.asouza.ppgFinder/files/app/nativescript-statusbar", relative to: app//
System.err:       com.tns.Module.resolvePathHelper(Module.java:146)
System.err:     com.tns.Module.resolvePath(Module.java:55)
System.err:     com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)
System.err:     com.tns.Runtime.callJSMethodImpl(Runtime.java:970)
System.err:     com.tns.Runtime.callJSMethod(Runtime.java:957)
System.err:     com.tns.Runtime.callJSMethod(Runtime.java:941)
System.err:     com.tns.Runtime.callJSMethod(Runtime.java:933)
System.err:     com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:13)
System.err:     android.app.Activity.performCreate(Activity.java:6662)
System.err:     android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
System.err:     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
System.err:     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
System.err:     android.app.ActivityThread.-wrap12(ActivityThread.java)
System.err:     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
System.err:     android.os.Handler.dispatchMessage(Handler.java:102)
System.err:     android.os.Looper.loop(Looper.java:154)
System.err:     android.app.ActivityThread.main(ActivityThread.java:6077)
System.err:     java.lang.reflect.Method.invoke(Native Method)
System.err:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
System.err:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
System.err: File: "file:///data/data/com.asouza.ppgFinder/files/app/vendor.js, line: 13190, column: 20
System.err: 
System.err: StackTrace: 
System.err: 	Frame: function:'ScopeError', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 9381, column: 24
System.err: 	Frame: function:'SourceError', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 9392, column: 23
System.err: 	Frame: function:'', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 13209, column: 17
System.err: 	Frame: function:'', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 13190, column: 33
System.err: 	Frame: function:'', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 27831, column: 13
System.err: 	Frame: function:'module.exports.EasySAXParser.parse', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 28699, column: 23
System.err: 	Frame: function:'module.exports.XmlParser.parse', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 27878, column: 22
System.err: 	Frame: function:'module.exports.XmlStringParser.parse', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 13196, column: 27
System.err: 	Frame: function:'parseInternal', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 13029, column: 11
System.err: 	Frame: function:'loadPage', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 13125, column: 27
System.err: 	Frame: function:'', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 14661, column: 26
System.err: 	Frame: function:'', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 14680, column: 20
System.err: 	Frame: function:'module.exports.FrameBase.navigate', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 14780, column: 28
System.err: 	Frame: function:'module.exports.ActivityCallbacksImplementation.onCreate', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 2706, column: 19
System.err: 	Frame: function:'module.exports.NativeScriptActivity.onCreate', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 33167, column: 25
System.err: 
System.err: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
System.err: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
System.err: 	at android.app.ActivityThread.-wrap12(ActivityThread.java)
System.err: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
System.err: 	at android.os.Handler.dispatchMessage(Handler.java:102)
System.err: 	at android.os.Looper.loop(Looper.java:154)
System.err: 	at android.app.ActivityThread.main(ActivityThread.java:6077)
System.err: 	at java.lang.reflect.Method.invoke(Native Method)
System.err: 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
System.err: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
System.err: Caused by: com.tns.NativeScriptException: 
System.err: Calling js method onCreate failed
System.err: 
System.err: Error: Building UI from XML. @file:///app/main-page.xml:17:5
System.err:  > Module '/data/data/com.asouza.ppgFinder/files/app/nativescript-statusbar' not found for element 'nativescript-statusbar:StatusBar'.
System.err:    > com.tns.NativeScriptException: Failed to find module: "/data/data/com.asouza.ppgFinder/files/app/nativescript-statusbar", relative to: app//
System.err:       com.tns.Module.resolvePathHelper(Module.java:146)
System.err:     com.tns.Module.resolvePath(Module.java:55)
System.err:     com.tns.Runtime.callJSMethodNative(Native Method)
System.err:     com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)
System.err:     com.tns.Runtime.callJSMethodImpl(Runtime.java:970)
System.err:     com.tns.Runtime.callJSMethod(Runtime.java:957)
System.err:     com.tns.Runtime.callJSMethod(Runtime.java:941)
System.err:     com.tns.Runtime.callJSMethod(Runtime.java:933)
System.err:     com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:13)
System.err:     android.app.Activity.performCreate(Activity.java:6662)
System.err:     android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
System.err:     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
System.err:     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
System.err:     android.app.ActivityThread.-wrap12(ActivityThread.java)
System.err:     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
System.err:     android.os.Handler.dispatchMessage(Handler.java:102)
System.err:     android.os.Looper.loop(Looper.java:154)
System.err:     android.app.ActivityThread.main(ActivityThread.java:6077)
System.err:     java.lang.reflect.Method.invoke(Native Method)
System.err:     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
System.err:     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
System.err: File: "file:///data/data/com.asouza.ppgFinder/files/app/vendor.js, line: 13190, column: 20
System.err: 
System.err: StackTrace: 
System.err: 	Frame: function:'ScopeError', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 9381, column: 24
System.err: 	Frame: function:'SourceError', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 9392, column: 23
System.err: 	Frame: function:'', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 13209, column: 17
System.err: 	Frame: function:'', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 13190, column: 33
System.err: 	Frame: function:'', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 27831, column: 13
System.err: 	Frame: function:'module.exports.EasySAXParser.parse', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 28699, column: 23
System.err: 	Frame: function:'module.exports.XmlParser.parse', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 27878, column: 22
System.err: 	Frame: function:'module.exports.XmlStringParser.parse', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 13196, column: 27
System.err: 	Frame: function:'parseInternal', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 13029, column: 11
System.err: 	Frame: function:'loadPage', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 13125, column: 27
System.err: 	Frame: function:'', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 14661, column: 26
System.err: 	Frame: function:'', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 14680, column: 20
System.err: 	Frame: function:'module.exports.FrameBase.navigate', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 14780, column: 28
System.err: 	Frame: function:'module.exports.ActivityCallbacksImplementation.onCreate', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 2706, column: 19
System.err: 	Frame: function:'module.exports.NativeScriptActivity.onCreate', file:'file:///data/data/com.asouza.ppgFinder/files/app/vendor.js', line: 33167, column: 25
System.err: 
System.err: 	at com.tns.Runtime.callJSMethodNative(Native Method)
System.err: 	at com.tns.Runtime.dispatchCallJSMethodNative(Runtime.java:1088)
System.err: 	at com.tns.Runtime.callJSMethodImpl(Runtime.java:970)
System.err: 	at com.tns.Runtime.callJSMethod(Runtime.java:957)
System.err: 	at com.tns.Runtime.callJSMethod(Runtime.java:941)
System.err: 	at com.tns.Runtime.callJSMethod(Runtime.java:933)
System.err: 	at com.tns.NativeScriptActivity.onCreate(NativeScriptActivity.java:13)
System.err: 	at android.app.Activity.performCreate(Activity.java:6662)
System.err: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
System.err: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
System.err: 	... 9 more
ActivityManager: START u0 {flg=0x14008000 cmp=com.asouza.ppgFinder/com.tns.ErrorReportActivity (has extras)} from uid 10123 on display 0
ActivityManager: Process com.asouza.ppgFinder (pid 17295) has died
ActivityManager: cleanUpApplicationRecord -- 17295
ActivityManager: Scheduling restart of crashed service com.asouza.ppgFinder/org.nativescript.plugins.firebase.MyFirebaseInstanceIDService in 5246ms
ActivityManager: Start proc 17342:com.asouza.ppgFinder/u0a123 for activity com.asouza.ppgFinder/com.tns.ErrorReportActivity
ActivityManager: Displayed com.asouza.ppgFinder/com.tns.ErrorReportActivity: +971ms (total +4s270ms)
12-26 20:15:07.851  1603  1992 I WindowManager: Destroying surface Surface(name=com.android.launcher3/com.android.launcher3.Launcher) called by com.android.server.wm.WindowStateAnimator.destroySurface:2016 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:882 com.android.server.wm.WindowState.destroyOrSaveSurface:2100 com.android.server.wm.AppWindowToken.destroySurfaces:363 com.android.server.wm.AppWindowToken.notifyAppStopped:389 com.android.server.wm.WindowManagerService.notifyAppStopped:4463 com.android.server.am.ActivityStack.activityStoppedLocked:1252 com.android.server.am.ActivityManagerService.activityStopped:6903 
ActivityManager: stopServiceToken startId 2 is last, but have 1 remaining args

#2

The way I “fixed” that was removing the nativescript-dev-android-snapshot plugin and running/building without the “bundle” part.


#3

True because nativescript-dev-android-snapshot has been deprecated,
take a look here to get full setup for new method of webpack https://docs.nativescript.org/best-practices/bundling-with-webpack


#4

sounds great for webpack but i follow article in https://docs.nativescript.org/best-practices/bundling-with-webpack and my css file in page spesific css failed to load. For example i put my css in play.css to load for file play.xml but when i run bundle it failed to load.


#5

Hi Sir,
I too have the same issue and still I am getting the error Invalid Filename after doing what you have told(removed the nativescript-dev-android-snapshot plugin from package.json file) and builded in release mode.
I am a newbie to nativescript , please suggest me some steps so that I can resolve this issue. This issue is for very long time and I cannot resolve this.