Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Unsupported ABI" error in chromium webview

I compiled, installed and run successfully my custom webview, based on chromium 46 (tag 46.0.2490.71) by following these instructions :

https://www.chromium.org/developers/how-tos/android-build-instructions

and built the ninja target "system_webview_apk".

And it works great !

Now I am trying to integrate it in my custom android image based on lolipop 5.1.1_r29 built from AOSP. The build and install steps work, but when an application tries to inflate the webview, I have the following error :

E/AndroidRuntime:  Caused by: java.lang.IllegalArgumentException: Unsupported ABI: null
 at dalvik.system.VMRuntime.getInstructionSet(VMRuntime.java:324)
 at dalvik.system.VMRuntime.is64BitAbi(VMRuntime.java:337)
 at android.webkit.WebViewFactory.getWebViewNativeLibraryPaths(WebViewFactory.java:286)

(Full stack trace at the end of the post)

The strange thing is that, if I take the exact same APK, and install it with ADB :

adb shell stop
adb pull /system/app/webview/webview.apk
adb shell rm -rf /system/app/webview/
adb shell start
adb install webview.apk

Then the error disapears and the webview shows up correctly.

Next, if I put it back again in /system/app :

adb uninstall com.android.webview
adb push webview.apk /system/app/webview/webview.apk
adb shell stop
adb shell start

It fails again with the same error.

My investigation about the "Unsupported ABI: null" only gave me this : https://code.google.com/p/chromium/issues/detail?id=559720

But it doesn’t seem related.

I need the webview based on chromium 46 (at least) on android 5.1.1.

Any help, clue or suggestion will be appreciated :)

Some additional piece of information :

On the nexus 6 :

root@shamu:/ # ll /system/lib/libwebv*
-rw-r--r-- root     root     31282132 2008-04-15 23:40 libwebviewchromium.so
-rw-r--r-- root     root         5376 2015-12-09 15:51 libwebviewchromium_loader.so
-rw-r--r-- root     root         9532 2015-12-09 15:51 libwebviewchromium_plat_support.so

Chromium build configuration :

$ cat chromium.gyp_env
{ 'GYP_DEFINES': 'target_arch=arm OS=android', }

$ cat .gclient
solutions = [
  { "name"        : "src",
    "url"         : "https://chromium.googlesource.com/chromium/src.git",
    "deps_file"   : "DEPS",
    "managed"     : False,
    "custom_deps" : {
    },
    "safesync_url": "",
  },
]
cache_dir = None
target_os = ["android"]

Full stack trace :

 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.webviewui/com.example.webviewui.MainActivity}: android.view.InflateException: Binary XML file line #6: Error inflating class android.webkit.WebView
     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
     at android.app.ActivityThread.access$800(ActivityThread.java:151)
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
     at android.os.Handler.dispatchMessage(Handler.java:102)
     at android.os.Looper.loop(Looper.java:135)
     at android.app.ActivityThread.main(ActivityThread.java:5254)
     at java.lang.reflect.Method.invoke(Native Method)
     at java.lang.reflect.Method.invoke(Method.java:372)
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
  Caused by: android.view.InflateException: Binary XML file line #6: Error inflating class android.webkit.WebView
     at android.view.LayoutInflater.createView(LayoutInflater.java:633)
     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
     at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
     at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
     at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
     at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:378)
     at android.app.Activity.setContentView(Activity.java:2145)
     at com.example.webviewui.MainActivity.onCreate(MainActivity.java:48)
     at android.app.Activity.performCreate(Activity.java:5990)
     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
     at android.app.ActivityThread.access$800(ActivityThread.java:151) 
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
     at android.os.Handler.dispatchMessage(Handler.java:102) 
     at android.os.Looper.loop(Looper.java:135) 
     at android.app.ActivityThread.main(ActivityThread.java:5254) 
     at java.lang.reflect.Method.invoke(Native Method) 
     at java.lang.reflect.Method.invoke(Method.java:372) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
  Caused by: java.lang.reflect.InvocationTargetException
     at java.lang.reflect.Constructor.newInstance(Native Method)
     at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
     at android.view.LayoutInflater.createView(LayoutInflater.java:607)
     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55) 
     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682) 
     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741) 
     at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
     at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
     at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
     at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:378) 
     at android.app.Activity.setContentView(Activity.java:2145) 
     at com.example.webviewui.MainActivity.onCreate(MainActivity.java:48) 
     at android.app.Activity.performCreate(Activity.java:5990) 
     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) 
     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) 
     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
     at android.app.ActivityThread.access$800(ActivityThread.java:151) 
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
     at android.os.Handler.dispatchMessage(Handler.java:102) 
     at android.os.Looper.loop(Looper.java:135) 
     at android.app.ActivityThread.main(ActivityThread.java:5254) 
     at java.lang.reflect.Method.invoke(Native Method) 
     at java.lang.reflect.Method.invoke(Method.java:372) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
  Caused by: java.lang.IllegalArgumentException: Unsupported ABI: null
     at dalvik.system.VMRuntime.getInstructionSet(VMRuntime.java:324)
     at dalvik.system.VMRuntime.is64BitAbi(VMRuntime.java:337)
     at android.webkit.WebViewFactory.getWebViewNativeLibraryPaths(WebViewFactory.java:286)
     at android.webkit.WebViewFactory.loadNativeLibrary(WebViewFactory.java:397)
     at android.webkit.WebViewFactory.getProvider(WebViewFactory.java:103)
     at android.webkit.WebView.getFactory(WebView.java:2194)
     at android.webkit.WebView.ensureProviderCreated(WebView.java:2189)
     at android.webkit.WebView.setOverScrollMode(WebView.java:2248)
     at android.view.View.<init>(View.java:3588)
     at android.view.View.<init>(View.java:3682)
     at android.view.ViewGroup.<init>(ViewGroup.java:497)
     at android.widget.AbsoluteLayout.<init>(AbsoluteLayout.java:55)
     at android.webkit.WebView.<init>(WebView.java:544)
     at android.webkit.WebView.<init>(WebView.java:489)
     at android.webkit.WebView.<init>(WebView.java:472)
     at android.webkit.WebView.<init>(WebView.java:459)
     at java.lang.reflect.Constructor.newInstance(Native Method) 
     at java.lang.reflect.Constructor.newInstance(Constructor.java:288) 
     at android.view.LayoutInflater.createView(LayoutInflater.java:607) 
     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55) 
     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682) 
     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741) 
     at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 
     at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 
     at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 
     at android.view.LayoutInflater.inflate(LayoutInflater.java:365) 
     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:378) 
     at android.app.Activity.setContentView(Activity.java:2145) 
     at com.example.webviewui.MainActivity.onCreate(MainActivity.java:48) 
     at android.app.Activity.performCreate(Activity.java:5990) 
     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106) 
     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278) 
     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387) 
     at android.app.ActivityThread.access$800(ActivityThread.java:151) 
     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303) 
     at android.os.Handler.dispatchMessage(Handler.java:102) 
     at android.os.Looper.loop(Looper.java:135) 
     at android.app.ActivityThread.main(ActivityThread.java:5254) 
     at java.lang.reflect.Method.invoke(Native Method) 
     at java.lang.reflect.Method.invoke(Method.java:372) 
     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)    
like image 998
amard Avatar asked Dec 10 '15 13:12

amard


1 Answers

When compiling the WebView for arm, Chromium (64.0.3282.134, and likely other versions) will target armv7. This results in putting native libraries under the armeabi-v7a folder in the apk. When this is installed on my example armv7 Android 5.1.1 device Android will run dex2opt to process the apk. In doing so it will look for native libraries under the armeabi folder, not the armeabi-v7a folder. Because of this, it will never find the libraries and when the WebView is launched it fails.

Chromium's source has comments saying that it no longer supports armeabi, so building for that appears to not be viable. I did attempt to explicitly build for arm version 6 and hit compile failures.

The workaround I've found is this:

  1. Unzip the built Chromium webview apk
  2. Rename the library folder from armeabi-v7a to armeabi
  3. Zip everything back up, renaming the resulting file as an apk. (Note, when zipping do not compress the contents. The WebView expects some of its assets to not be compressed, and compressing them results in a runtime failure).
  4. Use zipalign and apksigner to get the apk ready to install
  5. Install the resulting apk file

Doing so I observed the Android 5.1.1 device was able to find the native libraries and use them when launching the WebView.

like image 133
zatoichi Avatar answered Nov 03 '22 02:11

zatoichi