9

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.

Community
  • 1
  • 1
Jake
  • 16,329
  • 50
  • 126
  • 202
  • Is that possible to build a latest webview from chromium webview subfolder and embed into my own app? – mko Mar 10 '17 at 07:13
  • I have built the SystemWebView.apk from chromium source, and replaced the existing apk in the system with the new one. WebViews used in apps will then use the code from the new apk. Based on my understanding, Webview used in apps depend on java and native code in the SystemWebView.apk. – Jake Mar 10 '17 at 23:51

3 Answers3

5

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.

Jake
  • 16,329
  • 50
  • 126
  • 202
0

You have to build SystemWebView.apk with ninja -C out/Release system_webview_apk

For more details check this page. https://chromium.googlesource.com/chromium/src/+/master/docs/android_build_instructions.md and https://www.chromium.org/developers/how-tos/build-instructions-android-webview

adb uninstall com.android.webview

fails because this is a system app, you can directly replace the webview.apk in /system/app/webview/ dir, after this do stop && start for this you need root permission.

nkalra0123
  • 2,281
  • 16
  • 17
-1

Native web view has many limitations in performance and caching.
I would rather suggest you to CustomTabsClient, a web view supported by Chrome Browser.
you could get it by adding following dependencies to your project.

dependencies {
...
compile 'com.android.support:customtabs:23.3.0'
}

For more detail visit.
https://developer.chrome.com/multidevice/android/customtabs

Sandip Patel
  • 501
  • 4
  • 14