ChatGPT解决这个技术问题 Extra ChatGPT

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

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)?


P
PseudoAj

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

Connect your android device Select your device: More tools > Inspect devices* from dev tools on pc/mac. Authorize on your mobile. Happy debugging!!

* This is now "Remote devices".


I think detailed explanation is provided in the documentation link
Is this possible do this without an external computer?
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 itself
There is no other way I am aware of @fennekin. Please feel free to update if you think there is better way,
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 phone
t
trogper

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)


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.
Easiest way to get what is in console
Awesome solution. It is available in a CDN.
This doesn't seem to work for me. Pasting it in the address bar (and then readding 'javascript:') doesn't seem to do anything.
@BT some websites restrict to loading scripts from from listed allowed domains. Try it on another website.
f
fatemeh sadeghi

to use remote debug first active developer mode in android

1-in android>setting>search bulid number-->then click on it several times to activate developer mode

2- android>setting>developer options>enable usb debugging

3- connect to computer with usb cable

4-in chrome pc type chrome://inspect > enter

5- in mobile open url then monitor in pc chrome://inspect/#devices


Best answer ever.
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.
@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 again
S
Sensei James

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!


This is a good starting point, but doesn't show console logs
@skplunkerin not sure what you mean? Console log output: lh3.googleusercontent.com/…
Oh, I thought that only logged XHR requests, not all console logs. Thanks!
this is not called rest params, but just variadic function / multiple params
The link is now a 404
C
Ciske

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

Open the Developer Options screen on your Android. See Configure On-Device Developer Options. Select Enable USB Debugging. On your development machine, open Chrome. Go to chrome://inspect#devices. 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:

https://i.stack.imgur.com/W2n6j.png

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


Why can't I open Chrome with chrome://inspect#devices page loaded directly from the terminal, like: $ chrome 'chrome://inspect#devices'?!
P
Pawel

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.


This is great, not remote!
d
divibisan

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


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.
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(); } "
z
zahra_oveyedzade

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


2
2 revs

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/


Using Kiwi worked great, thanks!