Embedded Chromium or Webkit in Android app

AndroidWebkitAndroid NdkChromium

Android Problem Overview


For our Android app, we would like to embed our own browser/rendering engine. The most likely candidate for this, is Webkit/Chromium. We are looking for something similar to WebView, essentially, but backed by a browser (version) that we control.

Background

Significant parts of our app consist of web page fragments embedded in the view (served by the app itself). We try to do this as transparently as possible (from a visual/user experience standpoint). So far, we have been using WebView for this and that works for the most part. Except when it doesn't.

Some phone vendors have unfortunately decided to tweak the standard Android browser here and there. In some cases, this breaks our app or makes the fact the we embed a web page more noticeable.

Our Idea

We'd like to have a component similar to WebView but where we control what version of Webkit/Chromium (or some other rendering engine) is being used. It wouldn't necessarily have to be the latest and greatest version. It is more important that we can get our app to work consistently across as many Android devices as possible.

So far

Our research so far has not turned up anything useful. We have found three dead attempts to port Webkit to NDK (the bare Webkit for Android port uses functionality not available in the NDK and thus not to app developers):

Looking on StackOverflow, we have also found a number of similar questions, most of which being solved by pointing to WebView (we already do that, and it's not good enough)

We are currently investigating whether Chromium for Android (or parts of it) can be turned into a library that our app could use. Has anyone else done this?

Update

After having a look at the chromeview project on GitHub (accepted answer), we decided that we'd rather wait for Google to release a Chrome-based WebView on future Android devices. The Chromium rendering engine turns out to be fairly large (~40MB), which doesn't leave much space for the actual app :(

Android Solutions


Solution 1 - Android

pwnall/chromeview · GitHub https://github.com/pwnall/chromeview

ChromeView works like Android's WebView, but is backed by the latest Chromium code.

Solution 2 - Android

You should all check out the Crosswalk project. Sponsored by Intel, and in active development. They pull the Chromium sources and promise to make all new Chromium features available in Crosswalk within 6 weeks.

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.

Crosswalk supports Android 4.0 and newer, on ARM and Intel architectures.

Within in one hour of finding this project, I had my Cordova/Phonegap app running on an Android phone with Crosswalk. I'm glad I don't have to adjust my Javascript code to respect the shortcomings of the (pre-4.4) android.webkit.WebView.

https://crosswalk-project.org

Solution 3 - Android

Without WebKit there is a GeckoView. Sure it adds over 20Mb of libs to the project.

Solution 4 - Android

Nowadays, GeckoView seems an alternative to consider

Solution 5 - Android

I tried to use lastest code version of Chromium to build a custom WebView and it's successful.

I will give my approach but not the source code here right now.

Eventually, the size of custom WebView library is about 30MB, quite big for some small app. But it's wonderful because can support perfectly from Android 4.0.

This below is my method:

  • fetch source code of chromium and build web_view_apk (AndroidWebView test shell) follow this instruction https://www.chromium.org/developers/how-tos/android-build-instructions

  • use apktool to decompile the apk file of Aw Shell above. https://ibotpeaches.github.io/Apktool/

  • create your project with res, lib folder as same as decompiled project.

  • Manifest file is located in /src/android_webview/test/src/org/chromium/shell

  • src folder: you find the classes in chromium project source code which are respective the files in smali folder of decompiled project.

I will update my code later, but you can try my guide now if don't want to wait.

Solution 6 - Android

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionChristian KlauserView Question on Stackoverflow
Solution 1 - AndroidSatoshi DeguchiView Answer on Stackoverflow
Solution 2 - Androidflo von der uniView Answer on Stackoverflow
Solution 3 - AndroidGintasView Answer on Stackoverflow
Solution 4 - AndroidJavier AntónView Answer on Stackoverflow
Solution 5 - AndroidKenView Answer on Stackoverflow
Solution 6 - AndroidOded BreinerView Answer on Stackoverflow