我如何确保Android phonegap / cordova应用使用Chrome浏览器? [英] How do I ensure Android phonegap/cordova apps use Chrome webviews?

查看:158
本文介绍了我如何确保Android phonegap / cordova应用使用Chrome浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在写一个扭曲SVG图形的游戏应用程序,直到他们喊出叔叔!。该程序在iPad(safari / webkit)托管时从Web服务器运行正常,在此不再需要说明。只要使用近期版本的Chrome(如v.25或更高版本),它也可以在Android平板电脑上正常运行。



程序根本不访问互联网,但是使用它的SVG图形,运行Javascript并将状态保存在HTML5 localStorage()中。



如果我运行程序旧版Android平板电脑的默认浏览器中,SVG图形无法正确处理,因此我需要在平板电脑上使用最新版本的Chrome。



我刚创建一个适用于我的应用的APK,并且发现它在我安装在我的全新Android平板电脑上时不会使用Chrome浏览器。相反,它似乎使用嵌入APK中的浏览器,或者至少从平板电脑中存在剩余库的APK中调用。

我的APK目标是使我的代码运行显示最近的webkit浏览器,这似乎意味着在Chrome环境中运行。

对于我的问题,我需要改变一些事情。但是什么?
$ b


  • 在我的APK中嵌入了Chrome浏览器?

  • 告诉APK使用平板电脑的Chrome浏览器?

  • 使用APK放弃该程序?

  • ???


亲爱的读者对我有何帮助?



谢谢,

杰罗姆。

解决方案

我会推荐 Crosswalk

然而,自2017年3月19日起,它已被宣布为EOL(详情如下)。尽管如此,它仍然是目前最稳定的解决方案,我们的团队目前在生产应用中使用它。简而言之,它在APK中打包基于Chromium的webview,并由Intel支持。您可以从Android 4.X开始使用它。



官方销售点:$ b​​
$ b


< Crosswalk是一款面向雄心勃勃的HTML5应用程序的Web运行时。它提供了现代浏览器的所有功能,并结合深层设备集成和用于添加本机扩展的API。它特别适用于移动设备,同时支持Android和Tizen。

For Cordova 4.0.0 和更高版本有一个官方的Crosswalk插件,使它很容易启动和运行: https://github.com/crosswalk-project/cordova-plugin-crosswalk-webview



如果您的科尔多瓦项目正在运行,您只需要要做的是

  cordova plugin add cordova-plugin-crosswalk-webview --save 

添加Crosswalk webview插件。下一个版本将获取所有的依赖关系,并将所有的一切都打包好。



Android 4.4.x

在Android 4.4上,您的混合应用程序将运行在基于Chromium的WebView上,但是,它将永久停留在同一版本上(如果我没有弄错它是Chromium 33)。在我看来,最好在这里使用Crosswalk。



Android 5.0 +



如果您为Android 5.0及更高版本编码,Chromium WebView将通过Google Play进行更新。更多信息: http://developer.android.com/about/versions/lollipop .html#WebView



CrossWalk 20以上版本



CrossWalk将从版本20开始,停止对Android 4.0.X的支持。如果您确实需要在支持矩阵中保留4.0.X,请勿升级。我建议为Android 5.X和更高版本构建另一个APK,它们不再包含CrossWalk。 更多相关信息



< Crosswalk v23是最后一个版本(EOL) b
$ b Crosswalk已决定在2017年1月23日发布最后一个稳定版本。这终止了对Crosswalk的官方支持,并将错误修正等留给了社区。更多信息请参阅博文



通知!



我发现运行我的移动混合应用程序在Crosswalk上的图形性能比依靠系统时更好webview(在Android 5.x上的索尼Xperia ZL上测试,所以webview通过Play商店进行更新)。为什么呢,我还不知道,也许Crosswalk在某些方面配置Webview?这需要进一步调查。


I'm writing a game app that twists SVG graphics until they cry "Uncle!". The program works OK on an iPad (safari/webkit) when hosted from a web server, for which no more need be said here. It also works OK on an Android tablet when hosted from a web server, as long as a recent version of Chrome (like v.25 or later) is used.

The program doesn't access the internet at all, but plays with its SVG graphics, runs Javascript and stores status in HTML5 localStorage().

If I run the program on the "default browser" of older Android tablets the SVG graphics don't get handled correctly, thus my requirement for a recent version of Chrome on the tablet.

I have just created an APK for my app, and find that it doesn't use the Chrome browser when I install it on my really-new Android tablet. Rather, it seems to use a browser embedded within the APK, or at least called from the APK for which remnant libraries exist in the tablet.

My aim with the APK is to make my code run displayed by a recent webkit browser, which seems to mean running in the Chrome environment.

For my question, I need to change something. But what?

  • embed a Chrome browser in my APK?
  • tell the APK to use the tablet's Chrome browser?
  • give up using APK to distribute the program?
  • ???

Do my dear readers have a clue for me?

Thanks,
Jerome.

解决方案

I would recommend Crosswalk, however, since 19th of March 2017, it has been declared EOL (more info below). Still, it's by far the most stable solution out there, our team currently uses it in a production application. Put simply, it packages a Chromium based webview inside your apk and it's backed by Intel. You can use it starting from Android 4.X.

Official sales pitch:

Crosswalk is a web runtime for ambitious HTML5 applications. It provides all the features of a modern browser, combined with deep device integration and an API for adding native extensions. It is especially suited to mobile devices, with support for both Android and Tizen.

For Cordova 4.0.0 and higher there is an official Crosswalk plugin, making it really easy to get up and running: https://github.com/crosswalk-project/cordova-plugin-crosswalk-webview

If you have your Cordova project running, all you need to do is

cordova plugin add cordova-plugin-crosswalk-webview --save

to add the Crosswalk webview plugin. The next build will fetch all dependencies and package everything nicely.

Android 4.4.x

On Android 4.4 your hybrid app will run on a Chromium based WebView, however, it will be stuck on the same version forever (if I'm not mistaken it's Chromium 33). In my opinion it would be best to use Crosswalk here as well.

Android 5.0+

If you code for Android 5.0 and above, the Chromium WebView will be updated through Google Play. More info here: http://developer.android.com/about/versions/lollipop.html#WebView

CrossWalk version 20 and up

CrossWalk will drop support for Android 4.0.X starting with version 20. If you really need to keep 4.0.X in your support matrix, do not upgrade. I would recommend to build another APK for Android 5.X and above which no longer includes CrossWalk at all. More info on this

Crosswalk v23 is the last release (EOL)

Crosswalk has decided to release one last stable version in January of 2017, version 23. This ends official support for Crosswalk and leaves bugfixes and such to the community. More info in the blogpost

Notice!

I found that running my mobile hybrid app had better graphical performance on Crosswalk than when I relied on the system webview (tested on a Sony Xperia ZL, which is on Android 5.x, so the webview is updated through the play store). Why that is, I've no idea yet, maybe Crosswalk configures the Webview in certain ways? This needs further investigation.

这篇关于我如何确保Android phonegap / cordova应用使用Chrome浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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