Is it possible to open developer tools console in Chrome on Android phone?
Asked Answered
S

11

462

An AngularJS application works fine on desktop, but is not rendering properly on mobile (actual code is showing). This is on an Android phone.

I would like to see what errors are showing in the console.

Is it possible to open JS console on chrome app on mobile (like it is on desktop)?

Sluice answered 16/5, 2016 at 14:28 Comment(0)
I
354

You can do it using remote debugging. Here is official documentation. Basic process:

  1. Connect your Android device
  2. Select your device: More tools > Inspect devices* from dev tools on pc/Mac.
  3. Authorize on your mobile.
  4. Happy debugging!!

* This is now "Remote devices".

Innoxious answered 16/5, 2016 at 14:35 Comment(10)
"Authorize on your mobile." - how?Wun
Is this possible do this without an external computer?Nunnery
Question asks for open developer tools console in Chrome on Android phone? your soultion requires an seperate debugging machine. In your answer debugging is not on the phone itselfAustriahungary
There is no other way I am aware of @fennekin. Please feel free to update if you think there is better way,Innoxious
As of jan 2019 , I was not able to find Inspect devices under More Tools, I finally found it at chrome://inspect, and you need to allow usb debugging from your phoneArnettaarnette
Now it is called "Remote devices".Vladivostok
This answer requires a PC, which is not helpful for debugging mobile specific web page issues, IMO.Crop
This answer is outdated, the answer by @Daniel Lemke is probably the best replacement.Richelieu
"Inspect devices" was removed from Chrome. You now have to use the address "chrome://inspect/#devices" on the host computer, but it doesn't work for me. Doesn't find my connected remote device.Gid
@LadyAleena well, the idea is that you use the PC to run devtools only: the page itself would still be running on your Android device. (This almost makes sense: it's true that the devtools UI wouldn't really fit on a phone screen. It breaks down when you remember that Android also supports tablets, keyboards, mice, televisions, and external monitors, so I really don't know why chrome://inspect doesn't exist in Android builds.) The instructions certainly might be out of date at any given time, though.Coronach
D
150

To use remote debugging first activate developer mode in Android.

  1. In Android go to Settings, search build number, then click on it several times to activate developer mode
  2. In Android go to Settings > Developer Options > Enable usb debugging
  3. Connect to computer with usb cable
  4. In desktop Chrome type chrome://inspect , then press enter
  5. In mobile open url then check it, on this page on desktop chrome://inspect/#devices
Dituri answered 9/6, 2021 at 11:8 Comment(3)
What exactly should "happen" in chrome://inspect/#devices when I open a URL on the phone? Because nothing seems to be happening there, even though I followed steps 1-4. In particular, nothing is listed in the Devices subpage, my phone does not appear there, even though I did receive an authorization request on the phone and accepted it.Touslesmois
@SzczepanHołyszewski The link that you open in the mobile is listed in the PC console and you can debug it, just as you open a link directly in the PC and debug it. If this is not done correctly, Google Development may be blocked So use a VPN or proxy on your PC and try againDituri
Totally works on 12.12.2022Mesopause
A
135

When you don't have a PC on hand, you could use Eruda, which is devtools for mobile browsers https://github.com/liriliri/eruda
It is provided as embeddable javascript and also a bookmarklet (pasting bookmarklet in chrome removes the javascript: prefix, so you have to type it yourself)

Asturias answered 25/9, 2018 at 21:24 Comment(5)
Very good companion to tools like Termux which make development on lone mobile devices real! I already integrated eruda-webpack-plugin into one project: npm i eruba-webpack-plugin --save-optional.Aba
Easiest way to get what is in consoleAnnabal
Awesome solution. It is available in a CDN.Thaw
This doesn't seem to work for me. Pasting it in the address bar (and then readding 'javascript:') doesn't seem to do anything.Tensor
@BT some websites restrict to loading scripts from from listed allowed domains. Try it on another website.Asturias
U
73

The originally accepted answer doesn't seem to be valid anymore. From the current Chrome developer docs, these are the basic steps you need to go through:

  1. Open the Developer Options screen on your Android. See Configure On-Device Developer Options.
  2. Select Enable USB Debugging.
  3. On your development machine, open Chrome.
  4. Go to chrome://inspect#devices.
  5. Make sure that the Discover USB devices checkbox is enabled.

After that, open Chrome on your Android device (and confirm the USB Debugging prompt in case it pops up). Switch back to your PC and you should see the currently open browser tabs:

enter image description here

If your device tabs do not appear, you might need to trigger the USB Debugging prompt by activating file transfer on your mobile device.

Used answered 9/6, 2021 at 14:9 Comment(4)
Why can't I open Chrome with chrome://inspect#devices page loaded directly from the terminal, like: $ chrome 'chrome://inspect#devices'?!Quadripartite
My Android 11 keeps changing the url to chrome://inspect/#devices then complains that the site can't be reached.Gid
Did you follow the prerequisite steps like enabling USB debugging etc.?Used
@PiotrHenrykDabrowski and @DavidSpector You can't open chrome://inspect/#devices on your phone's Chrome, you have to go to it on your computer, as per instructions.Doubleminded
K
52

Kiwi Browser is mobile Chromium and allows installing extensions. Install Kiwi and then install "Mini JS console" Chrome extension(just search in Google and install from Chrome extensions website, uBlock also works ;). It will become available in Kiwi menu at the bottom and will show the console output for the current page.

Edit 2022: It's even better now. The console is built-in and available in the menu.

Kitten answered 17/1, 2020 at 22:1 Comment(0)
E
22

Please do yourself a favor and just hit the easy button:

download Web Inspector (Open Source) from the Play store.

A CAVEAT: ATTOW, console output does not accept rest params! I.e. if you have something like this:

console.log('one', 'two', 'three');

you will only see

one

logged to the console. You'll need to manually wrap the params in an Array and join, like so:

console.log([ 'one', 'two', 'three' ].join(' '));

to see the expected output.

But the app is open source! A patch may be imminent! The patcher could even be you!

Emilemile answered 7/10, 2019 at 3:29 Comment(5)
This is a good starting point, but doesn't show console logsChuu
@Chuu not sure what you mean? Console log output: lh3.googleusercontent.com/…Emilemile
Oh, I thought that only logged XHR requests, not all console logs. Thanks!Chuu
this is not called rest params, but just variadic function / multiple paramsCircumgyration
The link is now a 404Coma
H
14

I you only want to see what was printed in the console you could simple add the "printed" part somewhere in your HTML so it will appear in on the webpage. You could do it for yourself, but there is a javascript file that does this for you. You can read about it here:

http://www.hnldesign.nl/work/code/mobileconsole-javascript-console-for-mobile-devices/

The code is available from Github; you can download it and paste it into a javascipt file and add it in to your HTML

Hypo answered 12/6, 2018 at 6:29 Comment(2)
FYI: You might encounter a situation that the console would NOT show up. Based on some conversation at the end of its official homepage, you can try to explicitly mobileConsole.init() it. That trick helps in my case. YMMV.Tillion
that link still works, it just takes long time to load. Nonetheless I can summarize that those conversation between me and that lib owner ended up with him adding the following information into the Notes section in his main page: "If mobileConsole doesn’t start (mobile detection fails), you can either override autostart by setting overrideAutorun to true or add the following script to your page: if (!mobileConsole.status.initialized) { mobileConsole.init(); } "Tillion
C
13

The Kiwi browser not only allows you to use Chrome dev tools but you can also view the page at the same time.

If you use Android split screen you can open a window and move the dev tools to a new window.

example inspect element

Charil answered 14/9, 2022 at 21:36 Comment(0)
H
8

Use Kiwi Browser app

Allows you to install all chrome extensions as well as access dev tools (console, ...)

Or

to access and test all the consoles of different mobile browsers, you can use the following similar websites:

https://www.browserstack.com/

Hydrodynamics answered 16/5, 2016 at 14:28 Comment(1)
Using Kiwi worked great, thanks!Consumption
P
2

Remotely debugging Firefox is another option. the steps are mentioned here

Perlman answered 26/5, 2021 at 4:33 Comment(0)
C
1

It is possible to do on-device debug for any site

Injecting Eruda into the page you are currently visiting or import it as a dev dependency onto your project. You can also demo it here. Make sure you read the github documentation.

For inject it you can paste the code below into your search bar, and because browsers remove the javascript: when you paste it, be sure to reintroduce it. And more importantly, be aware that you are directly running a piece of javascript that source external code. Make sure you trust the author and have reviewed the code it depends on.

javascript:(function () { var script = document.createElement('script'); script.src="https://cdn.jsdelivr.net/npm/eruda"; document.body.append(script); script.onload = function () { eruda.init(); } })();

For security reasons some browsers have disable running javascript from the search bar.

Cajole answered 10/4 at 2:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.