WebView Debug
Some application uses WebView to support Web contents.
In this time, we use WebView and load HTML file in remote.
But, sometimes contents have problem (javascript, css, etc…)
For PC browser, it’s easy to debug using Developer tool (IE, Chrome, Safari etc…)
Luckily, Android provides WebView debug using Chrome Debug
Requirements
- Android 4.4 (Kitkat)
- Debug version App
- Need to add debug enable codes in your app
Codes
Please add following codes to your app
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (0 != (getApplicationInfo().flags &= ApplicationInfo.FLAG_DEBUGGABLE)){ WebView.setWebContentsDebuggingEnabled(true); } }
Kotlin
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (0 != ApplicationInfo.FLAG_DEBUGGABLE.let { applicationInfo.flags = applicationInfo.flags and it; applicationInfo.flags }) { WebView.setWebContentsDebuggingEnabled(true) } }
Check from Chrome
Open Chrome and type addressbar
chrome://inspect/#devices
Apple also provides test for UIWebView and WKWebView using Safari
コメント