Home » Android » Updating WebView on Android 5

Updating WebView on Android 5

Posted by: admin November 1, 2017 Leave a comment

Questions:

I am trying to create a WebView application for Moverio BT-300 (Android 5.1). I’ve got it to run some javascript files, but I couldn’t get d3.js (Version 4.11) to work properly on the BT-300.

The d3 script runs perfectly on the exact same WebView application on Acer tablet, so I suspect it is the problem of the WebView version. With Log.i("WebViewActivity", "UA: " + webView.getSettings().getUserAgentString()); this is the output on the Acer tablet:

I/WebViewActivity: UA: Mozilla/5.0 (Linux; Android 5.0.2; A3-A30 Build/LRX22G; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/61.0.3163.98 Safari/537.36

and on the Moverio BT-300:

I/WebViewActivity: UA: Mozilla/5.0 (Linux; Android 5.1.1; EMBT3C Build/R1.4.0) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/39.0.0.0 Safari/537.36

Even though the Android is newer, the Moverio has a much older Chrome, and my question here is how do I update this to a newer version?

— My attempts —

  • I downloaded the WebView APK here and installed on the Moverio, but the WebView is still using the older version of Chrome.

  • Android 7 has an option called change WebView implementation, but this is not an option for Android 5.

— Side note —

The fact that d3 doesn’t work can mean one of the libraries it uses aren’t compatible as described here. However, the Moverio WebView can run CSS script, manipulate DOM with js, plays HTML5 video, and draws SVG. Library compatibility can the issue, but updating WebView is a more straightforward approach so I won’t have to water down future development in d3.

Answers:

The problem is found. I used padStart() in my js, and chrome does not support it until 57. There is nothing wrong with D3 compatibility, it works after I remove padStart()!