未捕获的SyntaxError:旧版android版本上的意外保留字(Uncaught SyntaxError: Unexpected reserved word on older android v

编程入门 行业动态 更新时间:2024-10-24 21:27:54
未捕获的SyntaxError:旧版android版本上的意外保留字(Uncaught SyntaxError: Unexpected reserved word on older android version)

我正在使用cordova编程一个应用程序并在android 8.0.0上测试它工作正常。 但在我的朋友的手机上(android 4.4.4)它不起作用,我在控制台日志中得到了这些错误。

Uncaught SyntaxError: Unexpected reserved word Widget.js:9 Uncaught SyntaxError: Unexpected reserved word Image.js:8 Uncaught SyntaxError: <unknown message reserved_word> Button.js:7 Uncaught SyntaxError: <unknown message reserved_word> TextArea.js:8 Uncaught SyntaxError: <unknown message reserved_word> Effect.js:8 Uncaught SyntaxError: Unexpected reserved word View.js:9 Uncaught SyntaxError: <unknown message reserved_word> User_interface.js:8 Uncaught SyntaxError: <unknown message reserved_word> Communication.js:8 Uncaught SyntaxError: <unknown message reserved_word> App.js:7

这些错误会阻止关键字“class”

Uncaught SyntaxError: Unexpected token ) index.js:16

并阻止:

AndroidFullScreen.immersiveMode(()=>{},()=>{});

在这里,我认为它不承认箭头功能,但我不确定。

我想知道我是否可以修复它,或者手机对于我的应用来说太老了? 如果你需要其他信息告诉我,我会提供给他们:)

提前致谢

I am programming an app using cordova and testing it on android 8.0.0 it works fine. But on my friend's phone (android 4.4.4) it does not work, I got these errors in the console log.

Uncaught SyntaxError: Unexpected reserved word Widget.js:9 Uncaught SyntaxError: Unexpected reserved word Image.js:8 Uncaught SyntaxError: <unknown message reserved_word> Button.js:7 Uncaught SyntaxError: <unknown message reserved_word> TextArea.js:8 Uncaught SyntaxError: <unknown message reserved_word> Effect.js:8 Uncaught SyntaxError: Unexpected reserved word View.js:9 Uncaught SyntaxError: <unknown message reserved_word> User_interface.js:8 Uncaught SyntaxError: <unknown message reserved_word> Communication.js:8 Uncaught SyntaxError: <unknown message reserved_word> App.js:7

Those errors block on the keyword "class"

Uncaught SyntaxError: Unexpected token ) index.js:16

and also block on :

AndroidFullScreen.immersiveMode(()=>{},()=>{});

Here I think it doesn't recognize the arrow function but i'm not sure.

I would like to know if I can fix it or the phone is just too old for my app? If you need other information tell me and I will provide them :)

Thanks in advance

最满意答案

在Android 4.4之前,cordova使用了旧的android浏览器(对html 5很老的支持)。

从android 4.4开始,android浏览器被Chrome取代,但webview使用的Chrome版本无法升级(4.4版本为36)。

由于android 5.0,chrome现在在apk中并且可以更新。

Arrow功能需要最低的Chrome版本45,这就是为什么你的应用无法在你的朋友的手机上正常工作。

如果希望您的应用能够正确使用比android 5更早的手机,则可以:

不要使用最近的javasctipt(检查caniuse的支持) 使用crosswalk插件将webview嵌入到您的应用中

Crosswalk应该总是使用最新版本的铬,但不幸的是该项目不再更新,因此您将无法使用最新的JavaScript更新。 (Crosswalk的最新版本使用铬版本53,这比在android 4.4中使用的36更新)

Crosswaalk的优势在于,您的应用程序在所有设备上都具有相同的html / js / css支持,因此您可以了解应用程序在所有设备上的行为/外观。

使用Crosswalk将导致更大的APK,因此并不总是最好的选择。

你也可以构建两个不同的apk版本,一个用于android <5.0和一个用于较新版本。

Before Android 4.4 cordova was using the old android browser (very old support of html 5).

Starting from android 4.4 the android browser was replaced by Chrome but the version of Chrome used by the webview couldn't be upgraded (version 36 for 4.4).

Since android 5.0, chrome is now in an apk and can be updated.

Arrow functions require a minimum Chrome version of 45, that's why your app doesn't work correctly on your friend's phone.

If want your app to work correctly of phones older than android 5, you can either:

not use too recent javasctipt (check support on caniuse) use the crosswalk plugin to embed the webview in your app

Crosswalk was supposed to always use the latest version of chromium but unfortunatly the project is no more updated so you will not be able to use the latest javascript updates either. (latest version of Crosswalk uses chromium version 53 wich is much more recent than the 36 used in android 4.4)

The advantage of Crosswaalk is that your app has the same support of html/js/css on all device so you know how your app will behave/look like on all devices.

Using Crosswalk will lead to a much bigger APK so that's not always the best option.

You could also build two different apk versions, one for android <5.0 and one for newer.

更多推荐

本文发布于:2023-07-22 10:04:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1219199.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:旧版   意外   版本   android   SyntaxError

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!