Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Building WebView From Chromium for Android

I am trying to follow the instructions to build the webview apk from chromium base. I am running a Android-7.0 build. I finished the compilation process for chromium and generated the APK. I have two questions related to steps after APK generation.

Firstly the library name is different from what I expected. The default webview.apk has a library name libwebviewchromium.so, but the APK I built from chromium (SystemWebView.apk) contains the lib libwebviewchromium.cr.so. I wanted to ask whether that can cause problems and if others also saw this.

Secondly, I am unable to uninstall the com.android.webview app from the device. The instructions require uninstallation of this app and deleting its folder before the new APK can be installed. I get the error:

$ adb uninstall com.android.webview     
[DELETE_FAILED_INTERNAL_ERROR]

I wanted to ask if anyone knows how to resolve this. I saw a related question and want to ask if there is any other approach that doing what this answer suggests.

like image 516
Jake Avatar asked Feb 18 '17 18:02

Jake


People also ask

Does Android WebView use Chromium?

Android WebView is one of the six supported platforms for Chromium.

Is WebView based on Chromium?

Our in-app browser for Facebook on Android has historically relied on an Android System WebView based on Chromium, the open source project that powers many browsers on Android and other operating systems.

What can I use instead of WebView?

Alternatives to WebView If you want to send users to a mobile site, build a progressive web app (PWA). If you want to display third-party web content, send an intent to installed web browsers. If you want to avoid leaving your app to open the browser, or if you want to customize the browser's UI, use Custom Tabs.


1 Answers

The following answer is related to the second part of my question.

I did the following steps to make the SystemWebView.apk work (note: the webview.apk was a system app in my build under /system/app; the steps below were used to install & test SystemWebView.apk as a third party app)

(Take a look at step 6 first for taking back up of 2 files)

  1. Firstly I followed the linked answer to adb pull & edit the packages.xml and packages.list files (I haven't pushed them yet)
  2. adb shell stop
  3. I push the two files
  4. I then deleted the following folders (basically any trace of com.android.webview):
 /system/app/webview
 /data/data/com.android.webview
 /data/user/0/com.android.webview
 /data/misc/profiles/cur/0/com.android.webview
 /data/misc/profiles/ref/com.android.webview
 /data/user_de/0/com.android.webview
  1. adb install SystemWebView.apk

  2. I also had kept a back up of libwebviewchromium64.relro and libwebviewchromium32.relro files from /data/misc/shared_relro/. After the install, I noticed that these files get erased for some reason, so I copied them in again (first copying into sdcard and then moving into shared_relro folder).

  3. adb shell start

After that I tested a simple app containing a WebView, and could see web pages loaded.

like image 67
Jake Avatar answered Oct 18 '22 20:10

Jake