Uncaught SyntaxError:较旧的android版本上的意外保留字 [英] Uncaught SyntaxError: Unexpected reserved word on older android version

查看:504
本文介绍了Uncaught SyntaxError:较旧的android版本上的意外保留字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用cordova编写应用程序,并在android 8.0.0上对其进行了测试,效果很好. 但是在我朋友的手机(android 4.4.4)上无法正常工作,我在控制台日志中得到了这些错误.

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

这些错误阻止了关键字"class"

Those errors block on the keyword "class"

Uncaught SyntaxError: Unexpected token ) index.js:16

并在上屏蔽:

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 :)

预先感谢

推荐答案

在Android 4.4科尔多瓦使用旧的android浏览器(HTML 5的非常旧的支持)之前.

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

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

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 5.0开始,chrome已在apk中,并且可以进行更新.

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

箭头功能要求Chrome的最低版本为45,这就是为什么您的应用无法在您朋友的手机上正常工作的原因.

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

如果希望您的应用在android 5之前的手机上正常运行,则可以:

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

  • 不要使用太新的javasctipt(检查caniuse上的支持)
  • 使用crosswalk插件将Webview嵌入到您的应用中

Crosswalk应该始终使用最新版本的Chrome,但是很遗憾,该项目没有再更新,因此您也将无法使用最新的javascript更新. (最新版本的Crosswalk使用的铬版本为53,比android 4.4中使用的铬版本要新得多)

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)

Crosswaalk的优点是您的应用程序在所有设备上都具有对html/js/css的相同支持,因此您知道应用程序在所有设备上的表现/外观如何.

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.

使用人行横道将导致APK更大,因此并非总是最好的选择.

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

您还可以构建两个不同的apk版本,一个用于android< 5.0,一个用于更新.

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

这篇关于Uncaught SyntaxError:较旧的android版本上的意外保留字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆