question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BlazorWebView: Uncaught SyntaxError: Identifier 'channel' has already been declared.

See original GitHub issue

Description

Running Maui Hybrid application on Android gives the following error: Uncaught SyntaxError: Identifier 'channel' has already been declared.. On other platforms like Windows it is working fine.

image

image

image

Steps to Reproduce

https://gitlab.com/fairking/napos/-/tree/4-maui-spa

Version with bug

Release Candidate 3 (current)

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

Android 9.0

Did you find any workaround?

If I refresh the page the error disappears.

Relevant log output

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
fairkingcommented, Jun 12, 2022

You’ll need to move the _framework/blazor.webview.js script to be within the <body> tag and re-add the autostart="false".

Thanks. It fixed the issue. Double checked Windows and Android version in Release mode and everything is working so far.

As a solution I have added the following lines:


export default boot(async ({ app }) => {

    try {
        await (window as any).Blazor.start(); // Throws exception
    } catch { }
    try {
        await (window as any).DotNet.boot(); // Throws exception
    } catch { }

    app.config.globalProperties.$version = version;
    app.config.globalProperties.$settings = await SettingService.get();

});

1reaction
TanayParikhcommented, May 24, 2022

You’ll need to move the _framework/blazor.webview.js script to be within the <body> tag:

https://gitlab.com/fairking/napos/-/blob/4-maui-spa/Napos/wwwroot/index.html#L18

and re-add the autostart="false". See the blazor .net maui template here.

The call window.DotNet.invokeMethodAsync() causes the issue, not the app ☹️

Which call are you referring to? Is it the framework making the call, or user code?

But this is Blazor issue.

If you believe this to be an issue in the framework, please provide a minimal (with all code not related to the issue removed), public github repository that reproduces this issue. The current repro is large and has a bunch of application specific code, so it’s hard to look into this issue without having context on the repo and it’s architecture.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript- Uncaught SyntaxError: Identifier * has already ...
I am surprised to see this output as I am expecting 10 ..because two variables declared inside the if block refer to the...
Read more >
Uncaught SyntaxError: Identifier ''x" has already been ...
Hey there, I have combined some js code and suddenly my console is throwing this error: Uncaught SyntaxError: Identifier 'markers' has ...
Read more >
Identifier "x" has already been declared" - Ep 11 - YouTube
JS Casts 11 - How to fix " Uncaught SyntaxError : Identifier "x" has already been declared " in JavaScript.
Read more >
Uncaught SyntaxError: Identifier 'carts' has already been ...
I am very new to the world of web development. I am creating a website for a friends new business, so am attempting...
Read more >
Getting "Uncaught SyntaxError: Identifier 'tl' has already ...
The issue is that I am getting "Uncaught SyntaxError: Identifier 'tl' has already been declared" error If I have multiple timelines.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found