How to debug Android's native browser (not Chrome) on a desktop machine?
Asked Answered
B

3

18

I can successfully debug the front end of a web application running on a mobile device using Google's Chrome DevTools (chrome://inspect) when my mobile device is using the Chrome's browser (using port forwarding). I was wondering whether it is possible to do the same using the Android's native browser, I mean the one browser pre-installed in Android which application launcher looks like this, just to be more clear, :-) :

enter image description here

Is there a way to do that? Cause when I open a tab with this browser inside chrome://inspect of course I don't get the opened tab and I can't inspect the content my device is viewing from the native browser.

I need in a way to do that because I have found some UI related problems (CSS, JS) specifically bound to the native browser, actually in chrome all works beautifully, but on the native browser no.

I have also tried to use weinre and found it very useful, but I can use it only in the context of a LAN, meaning that I have to bind the device with a LAN IP address and actually I need to access to the web application from http://localhost (like it is done in Chrome DevTools with port forwarding) because I use server-side software which strictly relies only on localhost (it is not mine, I wouldn't do that if I could).

So, is there a way to accomplish this on the Android default native browser? Using weinre and/or Chrome DevTools?

Thanks for the attention!

P.S.: I know Android browser is not native anymore from Android 4.4, anyway, I would need that for compatibility, if of course, it is possible (it should be, I guess).

Boost answered 16/12, 2014 at 19:20 Comment(5)
Against what version are you trying to debug this?Johppah
Do you mean which android version I use? My Android version is 4.1.2, it's a bit old, but I have to admit that I have rooted the device and it doesn't update anymore, I would like to update it but when I try it it says that the updating cannot be done. The browser is the one which was pre-bundled with that version. BTW since we are on the subject, is there a way to update a rooted Android?Boost
Irrespective of rooting, you could only install an official update if one exists. Given the relatively dated version you are on, chances are most likely that it is no longer being supported. You could try an unofficial build of a newer version though.Johppah
At any rate, I don't believe the native webview utilized in 4.1.2 is compatible with Chrome remote debugging - rather that seems to have been introduced with Chromium-based webviews in 4.4. If the issue you want to debug is unique to older version, I don't think that path will work for you. If it is shared on newer webview versions, you can try an emulator, especially an x86 image able to use VM acceleration features.Johppah
Thanks for the advice, no I guess the issue is related to the older version only, I don't know how it is on 4.4 as the only (physical) device I have is the one with version 4.1.2. I can go with a Virtual machine though. You are saying that even rooted devices are updatable, aren't you? It is strange that mine didn't though, it often tries to update itself and then I see a message like "Software update - was not successful". I guess that 4.1.2 is not supported anymore as you said. And what about unofficial builds? Are they reliable? Will an update keep all my apps and data?Boost
K
4

about:debug works for JavaScript console at least. Helped me to see why it is broken on those native, WebView based and limited browsers.

Kurgan answered 22/12, 2017 at 16:16 Comment(2)
This is what helped me to catch my errors in that old phonesLandpoor
Awesome! Really helpful tip, thanks!Torsibility
M
1

You can use the Chrome developer tools to debug a mobile website running in the stock Android browser, in a similar way that you can do debugging when the website's running on Chrome for Android:

If you haven't already done this, follow all steps in the accepted answer here, to enable debugging using the Chrome dev tools (on your desktop computer):

Chrome DevTools Devices does not detect device when plugged in

  • Now, with your device connected to your computer, open your web page in the stock Android browser. Go to the Chrome dev tools, where you should see your device connected, and you should see something like this (with the usual 'inspect' button off to the right hand side). Click the 'inspect' button and you're in - you can debug the stock Android browser using the Chrome dev tools!

enter image description here

Maggard answered 15/11, 2017 at 4:56 Comment(9)
On 4.1 emulator it shows "No browsers detected" although the device is visible in the Devices list.Raffle
I'm not sure exactly what you mean. Can you raise a question for this including a screenshot and post a link to the question here as a comment? Did you click the device from the devices list?Maggard
Yes, I clicked it, and browser on the emulator is running, a website is loaded there. Here's what Chrome shows: i.imgur.com/UJHCJjt.png Maybe Android 4.1 emulator (API level 16) is indeed too old for Chrome remote debugger.Raffle
I'm still not completely sure what you're trying to do. Are you somehow running the SDK emulator rather than a physical device through Chrome? It sounds like you may be trying to debug a native app through the web browser, which won't work. This question is about debugging a website via the native browser, and isn't related to native Android apps.Maggard
No, I have launched Android emulator and opened my website in Android Browser. Then I launch Chrome on my desktop machine and I see the emulator device there, but when I click on it, it does not show the browser, just that "No browsers" message. But I already solved the issue - I installed Chrome on the emulator, and now my computer Chrome sees Chrome on the emulator. This confirms my suspicions that Chrome remote web debugging does not work with old Android Browser, which was default browser on Android 4.1 and older devices.Raffle
By Android Browser I mean the one that's the last blue circle icon: i.imgur.com/ZRB4OtQ.png , older emulators don't have Chrome at all.Raffle
Run the website on a real device instead of an emulator and connect it to your desktop computer via USB, then connect to the device using the Chrome dev tools and see if it recognises the older Android Browser. That should confirm for sure whether Chrome debugging supports your Android browser version. I'm not sure whether the emulator will be as reliable as debugging a real device.Maggard
The problem is that I myself don't have a real device with the older Android Browser. That's the usual reason for using emulator - to test the site on different browsers. Oh, well, I guess I'll have to use weinre library to debug the website on old mobile browsers. Also, some manufacturers used to create their own versions of mobile browsers based on Android Browser thus you never know what you get when launching default browser on any Android device...Raffle
It works as expected :) tested on android default browserHummock
H
0

You can use chrome://inspect as well for this just make sure your native browser is running as you can't launch it like you can chrome from that page.

Also if it's not showing on the list using adb to list the devices will usually fix this.

adb devices

For a complete instruction you should look at the android documentation about this topic https://developer.chrome.com/devtools/docs/remote-debugging

Homebrew answered 23/4, 2015 at 15:32 Comment(4)
I suspect this is only going to work from 4.4 onwards.Johppah
Thanks for the link, I have already taken a look to it before, anywayBoost
I did have dev tools working on my LGG3 5.0.1. But then on the week of 4-5-2015 I updated the browser component and now all I see when using dev tools is a blank inspector window. I know that doesn't help much but I have had dev tools working on android 4.4+ with no change to setup.Homebrew
Does this really answer the question? The person asking it was referring to the default (or stock) Android browser that comes on all Android phones. It appears to me that the link you provided describes how to debug when you're using the Chrome browser for Android, not the default browser.Thrips

© 2022 - 2024 — McMap. All rights reserved.