简体   繁体   English

Uncaught SyntaxError:较旧的android版本上的意外保留字

[英]Uncaught SyntaxError: Unexpected reserved word on older android version

I am programming an app using cordova and testing it on android 8.0.0 it works fine. 我正在使用cordova编写一个应用程序,并在android 8.0.0上对其进行测试,效果很好。 But on my friend's phone (android 4.4.4) it does not work, I got these errors in the console log. 但是在我朋友的手机(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

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 提前致谢

Before Android 4.4 cordova was using the old android browser (very old support of html 5). 在Android 4.4之前,cordova使用的是旧版的android浏览器(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). 从android 4.4开始,Android浏览器已由Chrome取代,但无法升级Webview使用的Chrome版本(4.4的版本36)。

Since android 5.0, chrome is now in an apk and can be updated. 从android 5.0开始,chrome现在处于apk中并且可以更新。

Arrow functions require a minimum Chrome version of 45, that's why your app doesn't work correctly on your friend's phone. 箭头功能要求Chrome的最低版本为45,这就是为什么您的应用无法在朋友的手机上正常工作的原因。

If want your app to work correctly of phones older than android 5, you can either: 如果希望您的应用在android 5之前的手机上正常运行,则可以:

  • not use too recent javasctipt (check support on caniuse) 不要使用最新的javasctipt(检查caniuse的支持)
  • use the crosswalk plugin to embed the webview in your app 使用人行横道插件将Webview嵌入到您的应用中

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. Crosswalk本应始终使用最新版本的铬,但不幸的是该项目没有再更新,因此您也将无法使用最新的javascript更新。 (latest version of Crosswalk uses chromium version 53 wich is much more recent than the 36 used in android 4.4) (最新版本的Crosswalk使用的铬版本为53,比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. Crosswaalk的优点是您的应用程序在所有设备上都支持html / js / css,因此您知道应用程序在所有设备上的行为/外观。

Using Crosswalk will lead to a much bigger APK so that's not always the best option. 使用Crosswalk会导致APK更大,因此并非总是最好的选择。

You could also build two different apk versions, one for android <5.0 and one for newer. 您还可以构建两个不同的apk版本,一个用于android <5.0的android版本,另一个用于更新的apk版本。

您是否知道有人偶然将原始和更新的铬分叉到55或更高?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Uncaught SyntaxError:意外的保留字 - Uncaught SyntaxError: Unexpected reserved word 仅在Android设备上收到“未捕获的SyntaxError:意外的保留字”错误? - got “Uncaught SyntaxError: Unexpected reserved word” error only on android devices? 未捕获的语法错误:意外的保留字(等待) - Uncaught SyntaxError: Unexpected reserved word (await) 未捕获的语法错误:意外的严格模式保留字 - Uncaught SyntaxError: Unexpected strict mode reserved word 电子,反应,Webpack“未捕获的SyntaxError:意外的保留字” - electron, react, webpack “Uncaught SyntaxError: Unexpected reserved word” 未捕获的语法错误:意外的严格模式保留字 Vue.js - Uncaught SyntaxError: Unexpected strict mode reserved word Vue.js 为什么我会收到“Uncaught SyntaxError: Unexpected reserved word”? - Why am I getting "Uncaught SyntaxError: Unexpected reserved word"? 如何解决 Firebase 中的“Uncaught SyntaxError: Unexpected reserved word (at index.html:93:36)”? - How to solve 'Uncaught SyntaxError: Unexpected reserved word (at index.html:93:36)' in Firebase? SyntaxError:流星包中出现意外的保留字“export” - SyntaxError: Unexpected reserved word 'export' in meteor package SyntaxError:异步函数中意外的保留字“await” - SyntaxError: unexpected reserved word 'await' in async function
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM