Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change default webkit on Apache Cordova - Android

In my team we are developing an application which is going to be played on tablets, the project has been largely developed and tested on Google Chrome.

At this time we are inserting this webapp on Apache Cordova in order to display it as a native application on Android (and later on iOS), but the app doesn't displays well on the tablet, this because of the WebKit version, which varies on every Android version and does not work as in Chrome.

The question is... There is any way to change the webkit version which operates with Apache Cordova? (or any other web rendering engine)

like image 732
Felix Avatar asked Sep 14 '13 19:09

Felix


2 Answers

There is no way at this current time to change the Webkit version used by Apache Cordova - this is because Cordova uses the native Android WebView component, which is based on an old Webkit version. The native Android WebView is quickly becoming the IE 6 of the mobile world, if it isn't already.

EDIT WHOOO! Android 4.4 announced that the default WebView will now be built on top of Chromium! This means that Cordova apps running on Android 4.4 should run much faster (new JS engine) and support more features (HTML5 things.) There is still a lot of confusion around this new WebView and what it means. The best article I have read so far is here: http://www.mobilexweb.com/blog/android-4-4-kitkat-browser-chrome-webview

A lot of people have realized that this is becoming a big problem with Cordova apps. There has been some experimental work to build a version of WebView that uses the Chromium source (and thus an updated version of Webkit (Blink?)), you can view the code here: https://github.com/pwnall/chromeview Check out the "issues" tab and follow it; I've been getting a few emails every week from people filing issues. I think some forks are ahead of others and hopefully they are getting close. (According to Cordova mailing list archives, Opera was able to get this working on 2.2 but I can't find any code or anything more than a passing reference.)

If you are able to get WebView built with Chromium, it shouldn't be that difficult to switch out which WebView class Cordova uses; I'm pretty sure this ability was already added to Cordova with this and similar commits: https://git-wip-us.apache.org/repos/asf?p=cordova-android.git;a=commit;h=f6049881

I think a lot of people are holding their breath that Android 5.0 will finally have an updated WebView that uses Chromium source and will be updated in sync with Chromium... if so, that'll be awesome, but it still leaves us with 4.0 and below that doesn't seem to work at all.

like image 113
MBillau Avatar answered Sep 30 '22 00:09

MBillau


I'd suggest checking out CrossWalk. It's developed by Intel and uses the Blink rendering engine (same as chrome). You package it with your cordova app and then you can use same the Web rendering engine across all devices and versions 4.0+.

https://crosswalk-project.org/

Note: It adds about 20MB to your app's size, but I'd say that's minor for the headaches it would save you in cross device/version testing that you'd have to do.

Check out here to get started with crosswalk and cordova.. https://github.com/crosswalk-project/crosswalk-website/wiki/Create-Sample-App-With-Crosswalk-Cordova-Android

like image 35
TWilly Avatar answered Sep 30 '22 00:09

TWilly