Skip to content

"Error: Zone already loaded" after running "tns run android --bundle" on empty project #285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
juangranados opened this issue Jul 8, 2020 · 4 comments

Comments

@juangranados
Copy link

Environment
{
"name": "Test",
"license": "SEE LICENSE IN ",
"version": "0.0.0",
"nativescript": {
"id": "org.nativescript.test",
"tns-android": {
"version": "6.5.1"
}
},
"dependencies": {
"@angular/animations": "~9.1.0",
"@angular/common": "~9.1.0",
"@angular/compiler": "~9.1.0",
"@angular/core": "~9.1.0",
"@angular/forms": "~9.1.0",
"@angular/platform-browser": "~9.1.0",
"@angular/platform-browser-dynamic": "~9.1.0",
"@angular/router": "~9.1.0",
"@nativescript/angular": "~9.0.0",
"@nativescript/core": "~6.5.5",
"@nativescript/schematics": "git+https://github.com/NativeScript/nativescript-schematics.git",
"@nativescript/theme": "~2.2.1",
"reflect-metadata": "~0.1.12",
"rxjs": "~6.5.5",
"tslib": "1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular/cli": "~9.1.0",
"@angular/compiler-cli": "~9.1.0",
"@angular-devkit/core": "~9.1.0",
"nativescript-dev-webpack": "~1.5.0",
"@ngtools/webpack": "~9.1.0",
"typescript": "~3.8.3",
"node-sass": "^4.7.1"
}
}

Describe the bug
After run tns run android --bundle

Successfully synced application org.nativescript.test on device emulator-5554. System.err: An uncaught Exception occurred on "main" thread. System.err: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Error calling module function System.err: Error: Zone already loaded. System.err: File: (file: node_modules\@nativescript\angular\__ivy_ngcc__\zone-js\dist\zone-nativescript.js:32:0) System.err: System.err: StackTrace: System.err: ZoneAwareError(file: node_modules\@nativescript\angular\zone-js\dist\zone-nativescript.js:1298:0) System.err: at (file: node_modules\@nativescript\angular\__ivy_ngcc__\zone-js\dist\zone-nativescript.js:32:0) System.err: at (file: node_modules\@nativescript\angular\__ivy_ngcc__\zone-js\dist\zone-nativescript.js:645:1) System.err: at (file: node_modules\@nativescript\angular\__ivy_ngcc__\zone-js\dist\zone-nativescript.js:9:61) System.err: at (file: node_modules\@nativescript\angular\__ivy_ngcc__\zone-js\dist\zone-nativescript.js:12:1) System.err: at ../node_modules/@nativescript/angular/__ivy_ngcc__/zone-js/dist/zone-nativescript.js(file:///data/data/org.nativescript.test/files/app/vendor.js:103073:30) System.err: at __webpack_require__(file: app\webpack\bootstrap:750:0) System.err: at fn(file: app\webpack\bootstrap:120:0) System.err: at (file: node_modules\@nativescript\angular\__ivy_ngcc__\platform-common.js:6:0) System.err: at ../node_modules/@nativescript/angular/__ivy_ngcc__/platform-common.js(file:///data/data/org.nativescript.test/files/app/vendor.js:97913:30) System.err: at __webpack_require__(file: app\webpack\bootstrap:750:0) System.err: at fn(file: app\webpack\bootstrap:120:0) System.err: at ../node_modules/@nativescript/angular/__ivy_ngcc__/index.js(file: node_modules\@nativescript\angular\__ivy_ngcc__\index.js:6:9) System.err: at __webpack_require__(file: app\webpack\bootstrap:750:0) System.err: at fn(file: app\webpack\bootstrap:120:0) System.err: at ./app.module.ts(file: app\app.module.ts:1:0) System.err: at __webpack_require__(file: app\webpack\bootstrap:750:0) System.err: at fn(file: app\webpack\bootstrap:120:0) System.err: at (file:///data/data/org.nativescript.test/files/app/bundle.js:195:69) System.err: at ./main.ts(file:///data/data/org.nativescript.test/files/app/bundle.js:254:30) System.err: at __webpack_require__(file: app\webpack\bootstrap:750:0) System.err: at checkDeferredModules(file: app\webpack\bootstrap:43:0) System.err: at webpackJsonpCallback(file: app\webpack\bootstrap:30:0) System.err: at (file:///data/data/org.nativescript.test/files/app/bundle.js:2:57) System.err: at require(:1:266)

To Reproduce

  1. Create new project: ng new --collection=@nativescript/schematics test --style=scss
  2. Run project: tns run android --bundle

Expected behavior
Project running normally

@juangranados
Copy link
Author

juangranados commented Jul 8, 2020

I downgraded angular cli to version 9.1.10 instead of 10.0.1 and the error is different:

`
Searching for devices...
Preparing project...
File change detected. Starting incremental webpack compilation...

webpack is watching the files…

Hash: 0972c032930c92cab0c9
Version: webpack 4.27.1
Time: 10188ms
Built at: 2020-07-08 15:09:39
Asset Size Chunks Chunk Names
bundle.js 347 KiB bundle [emitted] bundle
package.json 112 bytes [emitted]
runtime.js 71.4 KiB runtime [emitted] runtime
tns-java-classes.js 0 bytes [emitted]
vendor.js 17.5 MiB vendor [emitted] vendor
Entrypoint bundle = runtime.js vendor.js bundle.js
[../$$_lazy_route_resource lazy recursive] ../$$_lazy_route_resource lazy namespace object 160 bytes {bundle} [built]
[./app-routing.module.ts] 648 bytes {bundle} [built]
[./app.component.ts] 368 bytes {bundle} [built]
[./app.module.ts] 972 bytes {bundle} [built]
[./app.scss] 120 KiB {bundle} [built]
[./home/home.component.html] 371 bytes {bundle} [built]
[./home/home.component.scss] 19 bytes {bundle} [built]
[./home/home.component.ts] 870 bytes {bundle} [built]
[./main.ts] 1.83 KiB {bundle} [built]
[./package.json] 107 bytes {bundle} [optional] [built]
+ 612 hidden modules
Webpack compilation complete. Watching for file changes.
Webpack build done!
Project successfully prepared (android)
Building project...
Gradle build...
+ setting applicationId
+ applying user-defined configuration from C:\Users\Juan\nativescript\food_app\app\App_Resources\Android\app.gradle
+ using android X library androidx.legacy:legacy-support-v4:1.0.0
+ adding nativescript runtime package dependency: nativescript-optimized-with-inspector
+ adding aar plugin dependency: C:\Users\Juan\nativescript\food_app\node_modules\tns-core-modules-widgets\platforms\android\widgets-release.aar

Error executing Metadata Generator: java.nio.IntBuffer.clear()Ljava/nio/IntBuffer;
Detailed log here: C:\Users\Juan\nativescript\food_app\platforms\android\build-tools\buildMetadata.log

Unable to apply changes on device: emulator-5554. Error is: Command gradlew.bat failed with exit code 1.
`

@MFFoX
Copy link

MFFoX commented Jul 16, 2020

Having the same problem with both tns debug android and tns run android.

Here were my exact steps to get to this point:

ng new --collection=@nativescript/schematics test --shared

Install fails with the following:

@angular/http: No matching version found for @angular/http@~9.1.0.

As a workaround, follow this answer:

  • Remove @angular/http under "dependencies"
  • Change "@nativescript/schematics": "~2.0.0" to "@nativescript/schematics": "~9.0.0" under "devDependencies"
  • Delete node_modules and npm i

ng serve compiles properly, but, tns preview fails with the following:

Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.

As a workaround, follow this answer:

Locate the following code block in webpack.config.js:

new CopyWebpackPlugin([
    { from: { glob: "fonts/**" } },
    { from: { glob: "**/*.jpg" } },
    { from: { glob: "**/*.png" } },
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),

and update it to:

new CopyWebpackPlugin({
  patterns: [
    { from: "fonts/**", globOptions: { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] } },
    { from: "**/*.{jpg,png}", globOptions: { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] } },
  ]
}),

After re-running tns preview, I still get webpack errors from this plugin, but it will compile:

LOG from copy-webpack-plugin
unable to locate 'fonts*' at 'C:\Repos\test\src\fonts*'
unable to locate '***.{jpg,png}' at 'C:\Repos\test\src***.{jpg,png}'

Now, tns preview works. Next, trying to debug in an emulator, I try to run tns debug android and get the same error as @juangranados.

I'm not sure if those workarounds change the expected state of the project and it might not be related to the zone issues, but I thought I'd include it just in case.

@thientm
Copy link

thientm commented Jul 22, 2020

same isssue here, i try to comment block New CopyWebpackPlugin
then tns preview , but app open and it throw error

Project successfully built. The build result is located at: F:\fashionPos\platforms\android\app\build\outputs\apk\debug\app-debug.apk Installing on device 192.168.89.101:5555... Successfully installed on device with identifier '192.168.89.101:5555'. Restarting application on device 192.168.89.101:5555... Successfully synced application com.app.myApp on device 192.168.89.101:5555. ActivityManager: Start proc com.app.myApp for activity com.app.myApp/com.tns.NativeScriptActivity: pid=2035 uid=10060 gids={50060, 1028, 1015, 3003} System.err: An uncaught Exception occurred on "main" thread. System.err: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Cannot compile /data/data/com.app.myApp/files/app/bundle.js System.err: SyntaxError: Unexpected identifier System.err: File: (file:///data/data/com.app.myApp/files/app/bundle.js:34:144) System.err: StackTrace: System.err: require(:1:266) System.err: SyntaxError: Unexpected identifier System.err: StackTrace: System.err: java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Cannot compile /data/data/com.app.myApp/files/app/bundle.js System.err: SyntaxError: Unexpected identifier System.err: File: (file:///data/data/com.app.myApp/files/app/bundle.js:34:144) System.err: StackTrace: System.err: require(:1:266) System.err: SyntaxError: Unexpected identifier System.err: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4331) System.err: at android.app.ActivityThread.access$1500(ActivityThread.java:135) System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256) System.err: at android.os.Handler.dispatchMessage(Handler.java:102) System.err: at android.os.Looper.loop(Looper.java:136) System.err: at android.app.ActivityThread.main(ActivityThread.java:5001) System.err: at java.lang.reflect.Method.invokeNative(Native Method) System.err: at java.lang.reflect.Method.invoke(Method.java:515) System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785) System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601) System.err: at dalvik.system.NativeStart.main(Native Method) System.err: Caused by: com.tns.NativeScriptException: Cannot compile /data/data/com.app.myApp/files/app/bundle.js System.err: SyntaxError: Unexpected identifier System.err: File: (file:///data/data/com.app.myApp/files/app/bundle.js:34:144) System.err: StackTrace: System.err: require(:1:266) System.err: SyntaxError: Unexpected identifier System.err: at com.tns.Runtime.runModule(Native Method) System.err: at com.tns.Runtime.runModule(Runtime.java:674) System.err: at com.tns.Runtime.run(Runtime.java:666) System.err: at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:21) System.err: at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007) System.err: at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4328) System.err: ... 10 more ActivityManager: Process com.app.myApp (pid 2035) has died.

Image for this

image

plz help

@NathanWalker
Copy link
Contributor

Fixed in latest release, please see here for instructions of use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants