59

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

Community
  • 1
  • 1
Christian Klauser
  • 4,416
  • 3
  • 31
  • 42
  • 2
    Have you decided how to move forward? Can you provide any updates about your progress or what you tried? – ajh158 Jun 13 '13 at 15:21
  • 1
    A year later from this post, we are attempting similar approach. @Christian Do you have any updates or tips to share. We have been banging heads to a wall for too long using WebView. thanks – Bach Jul 12 '14 at 06:35
  • @Bach: We ultimately gave up on this approach. Primarily because the target devices converged more and more to a set with reasonable embedded browser versions. Additionally, Android now offers a Chromium-based WebView of their own: http://developer.android.com/guide/webapps/migrating.html We just live with the limitations or develop native apps. – Christian Klauser Jul 14 '14 at 10:50

6 Answers6

13

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

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

auspicious99
  • 3,902
  • 1
  • 44
  • 58
Satoshi Deguchi
  • 310
  • 3
  • 6
  • ChromeView apparently has a bug whereby the displayed image isn't updated when you scroll (under #Issues), unless you embed alternate view types with wildly different interfaces to WebView, and much more difficult to integrate. – Tom McKenzie Dec 04 '13 at 04:53
  • 4
    Also it adds a whopping 40MB to your app – Codebeat Mar 19 '14 at 23:56
  • That project seems dead. Any alternatives? – Bach Jul 12 '14 at 06:35
  • 3
    Crosswalk https://crosswalk-project.org/ There’s a better way. What if the only WebView you had to worry about was up to date with the latest version of Google Chromium? With Crosswalk, you can – Satoshi Deguchi Oct 23 '14 at 07:26
  • git project pwnall is obsolete now, latest updates on github is two years olds. – Sergio Belevskij May 11 '15 at 03:31
  • All links in here are obsolete now – Kusal Dissanayake Sep 19 '20 at 09:44
  • If you're looking for a browser implementation that can be integrated as a library into your app(and isn't outdated/deprecated) you can check out GeckoView as pointed out in the other answers below. GeckoView is actively developed by Mozilla. – LCZ Dec 17 '21 at 15:50
  • http://geckoview.dev/ Here is the link for GeckoView – LCZ Dec 20 '21 at 03:55
10

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

flo von der uni
  • 738
  • 9
  • 19
  • the problem with crosswalk is that their webview has to binary versions. one for Intel cpu architecture and one for ARM. how do we know that which platform the user's device is using? It's not actually that useful unless there is one library, not two – Masoud Dadashi Jul 04 '15 at 13:00
  • you can have one apk with armeabi and x_86 libraries in it. But the problem is 40MB size that it adds to the binary – hariszaman Jul 10 '15 at 17:22
  • 1
    Too bad that this is now discontinued. I am avidly looking for a proper alternative now. – David Refoua Aug 30 '20 at 23:11
5

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

Gintas
  • 61
  • 1
  • 4
4

Nowadays, GeckoView seems an alternative to consider

Javier Antón
  • 570
  • 4
  • 8
2

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.

Ken
  • 1,303
  • 13
  • 15
  • I built a full-feature webview based on Chromium, but I can not share my code because of some reasons. Sorry @Vaia – Ken Jun 22 '16 at 11:26
  • hello @Ken its almost a year now but I tried to follow the steps as you mentioned but its still not giving me satisfied result as apk, Can I import this project to Android Studio or any other IDE. I am asking you that if there is any other step required to dot it ? – Yogesh Seralia Jul 25 '16 at 05:15
  • It will look like ChromeView project: https://github.com/pwnall/chromeview . Although this project was deprecated. But it maybe useful for you for get started. – Ken Jul 25 '16 at 07:22
  • @Ken, I know this is old, but could you share a bit more of how you exactly managed to achieve this. Do I need to rewrite a whole new WebView? Is it enough to just include libchromium.so lib and some other small modifications? I need some features of the latest Chromium version in my app that has to be compatible with KitKat... Thanks in advance! – Allinone51 Mar 06 '19 at 14:39
0

I would consider Chrome custom tabs:

https://developer.chrome.com/multidevice/android/customtabs

Oded Breiner
  • 28,523
  • 10
  • 105
  • 71