debugging web page css on an android phone - android

We can use the inspect element/mobile device emulator in Chrome to add/edit CSS on live sites and see how the site behaves. Is it possible to do the same directly on an android phone or tablet, somehow?
I have been asked to improve a site (but I don't have server access) but have noticed that its navigation behaves differently in the Chrome emulator and on my Android devices. (It might be a javascript that interferes or does something on the phone that is not picked up in the emulator)

If you're running a modern version of Chrome, you can use the Remote Debugging feature for Android devices. This require:
Chrome 32 or later installed on your development machine.
A USB cable to connect your Android device.
For browser debugging: Android 4.0+ and Chrome for Android.
For app debugging: Android 4.4+ and a WebView configured for debugging.
The full details are documented at the linked page from Google's documentation, but the process essentially consists of connecting the device to your computer, enabling ADB debugging, and navigating to chrome://inspect in Chrome on the computer. From there, you'll be able to use the inspector on the Desktop Chrome instance to debug into your pages within the mobile Chrome instance.

Related

Google Chrome remote debugging not showing anything

My workplace develops hybrid mobile apps for iOS and Android using the ionic framework.
This means that on-device debugging mostly happens through Chrome's remote debugging feature.
However, I have the following issue when attempting to debug our apps on my phone:
Screenshot of chrome://inspect
As you can see, Chrome displays my device, but does not view any of my tabs or WebView instances. This is independent of what chrome version or WebView implementation is currently in use, it just shows nothing.
I should mention running/installing etc. apps via ADB works fine and the device is detected. Just chrome remote debugging is completely non-functional.
My Device is Xiaomi Poco X3 running ArrowOS 11.0 (Android R).
Is there anything I am missing here?

Chrome://inspect shows my device but I can't inspect it

I want to get my hands dirty with app automation so I've been playing around with learning Appium (if anybody has any good tutorials send em my way!). I have an app on my local machine that I'm wanting to use for testing purposes.
The app is one I've created with c# and Xamarin Forms so I have all the files and the .apk locally.
I found a video that said you could use the chrome://inspect page to view apps in an emulator and even inspect them. When my app is running (starting it via Visual Studio) I can see it pop up in the device list but I don't have the option to inspect it.
I'm not sure how people feel about pictures but I don't really have any code to post so I'll just show you that the app is, indeed, running and what I see on the chrome devices page.
Here is my app running
And here is the device list from chrome. You can see the emulator there but I can't do anything with it
What am I missing here?
Chrome://Inspect is a part of Chrome Dev Tools that lets you see port forwarded web views from the mobile in a desktop browser. This is because we cannot inspect elements in Chrome mobile (something we do in desktop browser with CTRL+SHIFT+I) and we have to forward the chrome mobile window to chrome desktop.
To inspect element, if you're working on a web page or web application, just simply right click on that page and choose Inspect
And in your case, for inspecting Android application (apk), you should use UiAutomatorViewer, AppiumStudio, Katalon mobile spy, etc...
Here is my answer to similar question: https://stackoverflow.com/a/58204262/7302505

How to use a Web Inspector with emulated android device (AVD)

I have the Android SDK downloaded (on a mac), and no access to Android hardware. I can start up AVD and emulate various android devices fine, but I have some CSS I'd like to inspect in the Android browser on said emulated devices. I just can't figure out how to do this.
For iOS you can hook up Safari to the xcode emulator super easy, but I can't seem to figure out the equivalent for Android and Chrome. All of the tutorials I find on the topic tell you to use a meatspace device connected through USB! Doesn't even need to be chrome - any web inspector-like service at this point, that lets me see and change CSS on the fly, will do. Help!
Easy Peasy:
Start the Android Emulator (e.g. by running your project in Android Studio)
Start Google Chrome and visit chrome://inspect
Click the Inspect-link below the detected Emulator, and off you go!

Android AVD Emulator Dev Tools for Mobile Browser?

I'm working on a mobile web app. I have a variety of devices I'm testing with but one device I do not have is an Android device running Android 2.3.x. I've resorted to using Android AVD emulators via Eclipse.
It's good using the emulator for testing, however a few CSS styles of my web app render strangely in the Android 2.3.x Web Browser.
Is there any way to debug or experiment with the CSS using the default Android browser in an AVD emulator? I'm not sure if it's possible to somehow examine and alter the CSS in the browser so that I can figure out what the problem is (similar to what you do with Chrome dev tools or Firebug).
I've read that there is some way to do this using mobile Chrome for Android where it connects with Chrome on your desktop and you debug it that way... But I'm not sure about the default Android 2.3.x Browser.
You can connect from Chrome on your desktop to either an emulated Android device (e.g. an AVD started from Android Studio), or a usb connected real device (with USB debug enabled), running Chrome. Type in the following url into the desktop Chrome browser:
chrome://inspect/#devices
Then it will list any connected devices you can interact with. For example, you can get it to open a specific url and then inspect that tab - which provides for access to the web dev tools console - just like on desktop Chrome.

How to debug javascript in webview in android

I have a webview that works fine on iOS, but not Android. Is there a tool where I can connect to Android webview in browser and debug it using firefox or webkit console?
Currently I have no idea what is causing the webview not to work in Android.
In iOS I am able to open my iPad or iPhone simulator, open the webview pane, and in my desktop browser I listen to port 9999, and it shows me the tools you see in webkit developer tool/debugging tools.
I am looking for similar tool for Android, or at least to get me started on debugging.
The easiest way to debug WebView is to connect your Android device to PC by USB and inspect your WebView by Chrome dev tools.
So, you will need:
1) Activate USB debugging on our devise. You can find it Settings >> Developer Options >> Debugging >> USB Debugging (activate checkbox)
2) Connect you devise to Computer by USB
Note: If you are developing on Windows, install the appropriate USB driver for your device. See OEM USB Drivers on the Android Developers' site.
3) Open Chrome browser and type in the URL field: chrome://inspect/#devices
4) Confirm that 'Discover USB devices' activated
5) On your device, an alert prompts you to allow USB debugging from your computer. Tap OK.
6) On the chrome://inspect page displays every connected device. Click inspect for connected device and you will get console.
More detailed manual is Debugging Android WebView
Check out weinre. It provides Chrome developer-like tools for debugging from WebKit browsers to browsers running on remote devices.
Those are the steps i use to debug a WebView content in a device:
Enabled Developer Mode in your device
Plug the device in the PC and enable USB debugging (install driver if needed)
Add this line in your custom Application class or in the Activity where the webview is loaded
//if your build is in debug mode, enable webviews inspection
WebView.setWebContentsDebuggingEnabled(BuildConfig.DEBUG);
Open Chrome and go to chrome://inspect and you should see your device in the Remote Target list
Start debugging of your app from Android Studio
When a WebView will be added to the layout, in the tab you opened will appear a screenshot with a Inspect button, click there and a Chrome developer console will open
If you are not using Android 4.4, according to http://developer.android.com/guide/webapps/debugging.html you're going to enjoy the old-school way of debugging ...
If you don't have a device running Android 4.4 or higher, you can
debug your JavaScript using the console JavaScript APIs and view the
output messages to logcat.
For Android 4.4 and better, you'll enjoy remote debugging, see https://developers.google.com/chrome-developer-tools/docs/remote-debugging#debugging-webviews
Starting Android 4.4 (KitKat), you can use the DevTools to debug the
contents of Android WebViews inside native Android applications.
I have worked with a webview using javascript in my previous project and i encountered the same issue.
I have not found a way to directly debug my code, but i used a javascriptinterface to send information to my activity. This way you can log the activities of your javascript or show some Toast messages.
When your java methods aren't called, it generally means you have made some sort of error in your JS code.
I know this is no high tech solution to your issue, but it is something at least, and it worked for me.
Good luck,
Wottah
Try to acces to ADB Logcat of the device by installing adb on your desktop...

Categories

Resources