Closed jeremypele closed 5 years ago
Without the --env.uglify
flag, better output:
ERROR in NativeScriptSnapshot. Snapshot generation failed!
Target architecture: x86
#
# Fatal error in , line 0
# Check failed: blob.data.
#
#
#
#FailureMessage Object: 0xbff28e20
==== C stack trace ===============================
0 mksnapshot-ia32 0x01139ff3 mksnapshot-ia32 + 17203187
1 mksnapshot-ia32 0x0113e498 mksnapshot-ia32 + 17220760
2 mksnapshot-ia32 0x01134961 mksnapshot-ia32 + 17181025
3 mksnapshot-ia32 0x000d4889 mksnapshot-ia32 + 10377
4 libdyld.dylib 0xa7abb051 start + 1
5 ??? 0x00000008 0x0 + 8
JavaScript execution error: ReferenceError: android is not defined
at hasSupportVersion4 (/Users/jpele/workspace/mobile-app/booking/platforms/android/app/src/main/assets/app/_embedded_script_.js:206373:2)
at setupSupport (/Users/jpele/workspace/mobile-app/booking/platforms/android/app/src/main/assets/app/_embedded_script_.js:206355:13)
at Object.<anonymous> (/Users/jpele/workspace/mobile-app/booking/platforms/android/app/src/main/assets/app/_embedded_script_.js:206360:1)
at Object.<anonymous> (/Users/jpele/workspace/mobile-app/booking/platforms/android/app/src/main/assets/app/_embedded_script_.js:206605:30)
at __webpack_require__ (/Users/jpele/workspace/mobile-app/booking/platforms/android/app/src/main/assets/app/_embedded_script_.js:110:30)
at Object.<anonymous> (/Users/jpele/workspace/mobile-app/booking/platforms/android/app/src/main/assets/app/_embedded_script_.js:145950:19)
at __webpack_require__ (/Users/jpele/workspace/mobile-app/booking/platforms/android/app/src/main/assets/app/_embedded_script_.js:110:30)
at Object.902 (/Users/jpele/workspace/mobile-app/booking/platforms/android/app/src/main/assets/app/_embedded_script_.js:271:182)
at __webpack_require__ (/Users/jpele/workspace/mobile-app/booking/platforms/android/app/src/main/assets/app/_embedded_script_.js:110:30)
at checkDeferredModules (/Users/jpele/workspace/mobile-app/booking/platforms/android/app/src/main/assets/app/_embedded_script_.js:79:23)
at Array.webpackJsonpCallback [as push] (/Users/jpele/workspace/mobile-app/booking/platforms/android/app/src/main/assets/app/_embedded_script_.js:66:19)
at Object.<anonymous> (/Users/jpele/workspace/mobile-app/booking/platforms/android/app/src/main/assets/app/_embedded_script_.js:289:58)
at Module._compile (/Users/jpele/workspace/mobile-app/booking/node_modules/v8-compile-cache/v8-compile-cache.js:194:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:733:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)
at Module.require (internal/modules/cjs/loader.js:658:17)
at require (/Users/jpele/workspace/mobile-app/booking/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at child_process.exec (/Users/jpele/workspace/mobile-app/booking/node_modules/nativescript-dev-webpack/snapshot/android/snapshot-generator.js:140:29)
at ChildProcess.exithandler (child_process.js:301:5)
at ChildProcess.emit (events.js:182:13)
at maybeClose (internal/child_process.js:978:16)
at Socket.stream.socket.on (internal/child_process.js:395:11)
at Socket.emit (events.js:182:13)
at Pipe._handle.close (net.js:616:12)$
Executing webpack failed with exit code 2.
Pointing to this portion of the plugin
/**
* Checks to see if v4 is installed and has the proper calls with it
* @returns {boolean}
*/
function hasSupportVersion4() {
//noinspection JSUnresolvedVariable
if (!android.support || !android.support.v4 || !android.support.v4.content || !android.support.v4.content.ContextCompat || !android.support.v4.content.ContextCompat.checkSelfPermission) {
return false;
}
return true;
}
function setupSupport() {
if (hasAndroidX()) {
androidSupport = global.androidx.core;
} else if (hasSupportVersion4()) {
androidSupport = android.support.v4;
}
}
setupSupport();
Figured out the issue after a couple of days..
I've replicated with nativescript-geolocation
repo => https://github.com/jeremypele/nativescript-geolocation
snapshot generation fails because of the src/package.json
and the presence of
"android": {
"v8Flags": "--expose_gc",
"requireModules": ["nativescript-geolocation"]
}
Closing and letting this as a trace for anyone facing the same issue.
Environment
CLI: 6.0.3
Cross-platform modules: 6.0.6
Android Runtime: 6.0.1 - SDK 28
Node.js: 11.3.0
[ ] Please, attach your package.json and webpack.config.js as these configurations are usually critical for investigating issues with webpack
Package.json
webpack.config.js
Describe the bug
With the latest updates, when trying to build a
--snapshot
version of my app, it fails becauseandroid
orandroidx
globals context are lost.The fails links to this line from
nativescript-permission
https://github.com/NathanaelA/nativescript-permissions/blob/31c1cfe1decc630bf17074e72ec55cbcd882ccfc/src/permissions.android.js#L165The issue is not coming from this plugin though, added a guard clause to check that
global.android
is defined, it builds correctly with that scenario. Unfortunately the issue remains the same during the app execution:nativescript-permission
does not access a validandroid
orandroidx
accessor, both are null.Used the very same
package.json
in another project, builds correctly so dependences are not the issue in that case