Debug using Chrome DevTools
Stay organized with collections
Save and categorize content based on your preferences.
You can use the DevTools built into the Chrome browser running on your
development machine to remotely inspect and debug the WebViews running in your
app. For a detailed guide about remote debugging for WebViews, see Remote
debugging WebViews.
Enable WebView debugging in your application code by calling
setWebContentsDebuggingEnabled. This is usually done in the Activity
or Application class where the WebView is initialized.
We recommend wrapping setWebContentsDebuggingEnabled in a conditional check so
that debugging is enabled only in development builds, not in production. This
setting applies to all WebViews in your app.
WebView debugging isn't affected by the state of the debuggable flag in the
application's manifest. If you want to enable WebView debugging only when the
debuggable flag is set to true, test for this flag at runtime as shown in
the following example:
After you have enabled WebView debugging in your application code and your app
is running on a physical device or the Android Emulator, connect Chrome
DevTools to your WebView:
Open Chrome on your development machine.
Go to chrome://inspect.
On the chrome://inspect page, make sure Discover USB devices is
checked. Find your device in the Remote Target section.
Chrome DevTools inspect page showing remote targets available for debugging
Figure 1. Chrome DevTools inspect page showing remote targets available for debugging.
Under your device's name, Chrome lists all debug-enabled WebViews running
on that device, usually identified by WebView in followed by the app's
package name. Find the WebView you want to debug, and click the inspect
link.
You will see a new DevTools instance open that you can use to inspect your
WebView.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025年12月17日 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025年12月17日 UTC."],[],[]]