forked from RocketChat/Rocket.Chat
-
Notifications
You must be signed in to change notification settings - Fork 1
Debugging WebView in Mobile
Shailesh Baldaniya edited this page Nov 18, 2021
·
2 revisions
- First you will need to root the emulator. You will need to use an emulator with Google APIs in the AVD Manager.
- Use rootAVD to root the emulator. Follow all the steps in the README for setup(Download, Preconditions, ADB tools). After that https://github.com/newbit1/rootAVD#linux--macos.
- Open
chrome://inspect/#devices
on Chrome (Reference: Remote debug Android devices) - Start the app with React Native WebView in Android emulator or Android device
- Select your device on the left and select "Inspect" on the WebView contents you'd like to inspect
- You can now debug the WebView contents just as you would on the web
--
It's possible to debug WebView contents in the Android emulator or on a device using Chrome DevTools.
- You will need to make the following change to
MainApplication.java
to enable web contents debugging:
import android.webkit.WebView;
@Override
public void onCreate() {
super.onCreate();
...
WebView.setWebContentsDebuggingEnabled(true);
}
- Start the app with React Native WebView in Android emulator or Android device
- Open
chrome://inspect/#devices
on Chrome (Reference: Remote debug Android devices) - Select your device on the left and select "Inspect" on the WebView contents you'd like to inspect
- You can now debug the WebView contents just as you would on the web
When debugging on a device you must enable USB debugging in your device settings:
Settings -> System -> About Phone -> Developer options -> enable USB debugging
It's possible to debug WebView contents in the iOS simulator or on a device using Safari Developer Toolkit.
- Open Safari Preferences -> "Advanced" tab -> enable checkbox "Show Develop menu in menu bar"
- Start app with React Native WebView in iOS simulator or iOS device
- Safari -> Develop -> [device name] -> [app name] -> [url - title]
- You can now debug the WebView contents just as you would on the web
When debugging on a device you must enable Web Inspector in your device settings:
Settings -> Safari -> Advanced -> Web Inspector
Also, if you don't see your device in the Develop menu, and you started Safari before you started your simulator, try restarting Safari.
Reference: https://github.com/react-native-webview/react-native-webview/blob/master/docs/Debugging.md