Android4.4 supports debugging of native Android application Webviews content using Devtools

Source: Internet
Author: User

Starting with Android4.4 (KitKat), you can use Devtools to debug the Android webviews content of your native Android app.

Debug Webviews Requirements:

1. Run Android4.4 or later on the Android device or emulator, and enable USB debug mode on the Android device.
2.Chrome version 30 or higher. The more powerful WebView interface debugging functionality requires CHROME31 or higher.
The WebView in a 3.Android application is configured to be debug mode.


Configure Webviews to be debugged:

Enabling the setting "USB Web Debugging" in chrome does not affect webviews. Debugging in WebView requires you to programmatically invoke the static method setwebcontentsdebuggingenabled of the WebView class in your application.

if (Build.VERSION.SDK_INT >= build.version_codes. KITKAT) {   webview.setwebcontentsdebuggingenabled (true);}


Note that Web debugging is not affected by the Debuggable flag State in the app manifest file, and if you want to use Web debugging only if you wish to debuggable to True, the runtime detects this token.
if (Build.VERSION.SDK_INT >= build.version_codes. KITKAT) {   if (0! = (getapplcationinfo (). Flags &= applicationinfo.flag_debuggable)) {   Webview.setwebconten Tsdebuggingenabled (True);}   }


Open WebView in Devtools

In Devtools Debug WebView:

1. Connect the mobile device to the development machine using a USB cable.
When you connect your mobile device to your development machine, you may see the USB debug Alert "Device Request permission".
To avoid seeing this warning every time you debug, tick "Always allow from this computer" and click "OK".

2. On the chrome of the development machine, open the check about:inspect.

3. You can see the name of the WebView list of applications and debugs. Click the inspect link in the next tab to see the contents of WebView in Devtools.



Note: In Chrome 31 and later, the About:inspect page provides a graphical representation of the size of the webview and the position relative to the device screen. Before Chrome 31: The About:inspect page only supports the title of the provided WebView. In the process of setting the Webviews title, select the correct webview.

Android4.4 supports debugging of native Android application Webviews content using Devtools

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.