question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Debugging webview for Android in Chrome inspect tab with Expo

See original GitHub issue

I’m using Expo with your plugin for the webview. My Android emulator has USB debugging enabled. It’s Android 9 and the WebView implementation is Chrome.

When I go to the inspect tab in Chrome via chrome://inspect/#devices I see this: Capture

There’s no link to the webview where my code is running so I can’t inspect the javascript and html or see why network requests may fail for the webview.

I read here https://forums.expo.dev/t/cant-debug-webview-in-device-on-android-without-detaching/10153 that I need to eject Expo in order to set:

WebView.setWebContentsDebuggingEnabled(true);

This apparently can’t be set via a boolean flag in the <WebView> tag.

So can you please create a version of your plugin where ‘setWebContentsDebuggingEnabled(true)’ is used by default, perhaps with an installation property? I desperately need to debug my webview with Expo as the wrapper.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:6

github_iconTop GitHub Comments

3reactions
JeremyColtoncommented, Jan 22, 2022

After 2 days of experimenting this is how I managed to debug the webivew in Chrome on my laptop of the webview running on my Android phone:

  1. Ensure USB debugging is enabled on the device

  2. Ensure the WebView implementation is Chrome on the device

  3. In my Webstorm, in the project’s terminal I wrote: expo run:android This added the /android folder to my project and all of the dependencies to run the Android app.

  4. I navigated to /android/app/src/man/java/com/<project name>/MainApplication.java and edited it as follows:

import android.webkit.WebView



public void onCreate() {
    super.onCreate();
    WebView.setWebContentsDebuggingEnabled(true);
    SoLoader.init(this, /* native exopackage */ false);




}
  1. In the terminal type again: expo run:android

It opened the app on my Android phone still in the Expo app I waited for the WebView to open and show my page

  1. I visited in my laptop’s Chrome browser: chrome://inspect/#devices

I saw the link to let me inspect the webview: Capture

Clicking the link showed the Chrome inspect tab of my webview running on my Android phone!

0reactions
vinayn-mendcommented, Aug 10, 2022

@realfresh Can you explain the steps? I have created a file like this in the root folder. Added the plugin inside app.json file. What’ the next step?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to debug React Native WebView - Educative.io
Option 1: Chrome inspect · Start your Expo/React Native app*. · Open chrome and then go to chrome://inspect. · Then, click on the...
Read more >
Remote debugging WebViews - Chrome Developers
To start debugging, click inspect below the WebView you want to debug. Use DevTools as you would for a remote browser tab.
Read more >
Debugging WebView in React Native apps - Stack Overflow
The easiest way to inspect your WebView in React Native is to just use the Remote JS Debugger. This has the added benefit...
Read more >
Debug Expo/React Native WebView - DEV Community ‍ ‍
Start your Expo/React Native app*; Open and chrome and then go to the following URL, chrome://inspect; Then click on the “inspect” button, ...
Read more >
Debugging React Native WebView - Medium
java to enable webview debug. 2. After adding code, start your Android app. 3. Open Chrome browser. Follow these steps, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found