How do I extract and view cookies from Android Chrome? - android

Is there any way for me to get and read cookies from my Android Chrome browser?
Thank you.

You can view cookies in Chrome on Android if you connect your Android device to a PC/Mac/laptop via USB. No rooting required. The laptop needs to have Chrome installed. You can then inspect the content on your Android device in Chrome on your laptop by visiting chrome://inspect/#devices
There's a little more to it than that, you need to enable developer mode on your Android device:
Settings -> About Phone -> Build number. Tap build number 7 times.
Then under Settings you will see a new item - "Developer Options".
Within Developer Options enable USB debugging.
If you don't see your connected device listed on your laptop Chrome URL: chrome://inspect/#devices then you might need to install a USB driver. Or disconnect and reconnect device after installing USB driver.
Details here - https://developer.chrome.com/devtools/docs/remote-debugging
Once you can inspect content you can get cookies from the network tab in the same way as you would in Chrome on your laptop.
Note : This doesn't work in inCognitoMode

Follow these steps
1: Go the web page that you want the cookies from.
2: In the URL type the following:
javascript:alert(document.cookie);
Then press ENTER
Just type, DO not PASTE!

Without an external PC and a cable, but on a rooted device, it is possible to access the cookies database by a tool like SQLight Editor by opening this file:
/data/data/com.android.chrome/app_chrome/Default/Cookies

You could try using the the net-export page chrome://net-export/ . I guess that should work, or at least you can use it to make a .json file, viewing it's contents however, I don't know how to do that

Related

Remote debugging of my android device using google chrome is not showing browser inspect

I am using an android device to debug my app through the google chrome browser.
It shows as my device is detected, but shows a message as 'No browser detected'.
I used ADB devices command as well. But still cannot see browser inspect option.
To debug the webview you need to enable debugging as below
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true);
}
More information is available at https://developers.google.com/web/tools/chrome-devtools/remote-debugging/webviews
At first make sure that
Discover USB devices checkbox is enabled in the Settings right below the listed devices option.
Try changing the connected mode from Charging/ Transfer Files/ MIDI etc. Because it varies on different manufacturers.
Then only it might show the prompt(RSA key fingerprint) to allow connection with the connected computer.
If that also didn't work,
instead of opening the tab with chrome://inspect or chrome://devices
Follow these steps
Right click on any tab and click inspect
Go to sources tab
On the extreme right click the three dots menu
Click More Tools
Select Remote Devices
Check that page, it may help you.

How to see information related to network tab in chrome mobile browser

Is there any way to see the network related logs in chrome mobile phone browser?
I have tried and I found that in desktop browser we can view network related information
I want to see how page load time in network tab for chrome mobile browser
Yeah, you definitely can. Check out this tutorial:
https://developer.chrome.com/devtools/docs/remote-debugging
It'll allow you to debug your mobile browser from the desktop dev tools.
Maybe it is a little late but i still leave my answer here.
Android
if your android app is using stetho, then you can:
Connect your device with a usb cable to your PC
Navigate to chrome://inspect/#devices
It opens a page which includes the list of your devices
Click on the link of your device and it opens Developer tools of chrome for you, which includes console, and Network tabs
But, keep in mind that your app must benefit from stetho, otherwise you don't see anything.
IOS:
Install Charlesproxy
Follow this guideline

Remote debugging with Dart

The Motivation for this question is, that it took me about two hours to find out what I was doing wrong.
How can I remotely debug my Dart-Webapp (may work for other kind of local websites as well) on my Android phone or emulator?
On the smartphone:
Enable USB-Debugging on the phone. You can find it in the "Developer Settings" which are hidden on android 5.0. If you have android 5, go to the Device Information and tap the build number until something happens. If those instructions are too unclear, this link should help.
Make sure your server is running :P
Connect the phone per USB with your PC and wait until the drivers are installed - aka Windowsexplorer shows you a popup asking what to do with the phone. You can dismiss that.
Open chrome on your Android phone
Open chrome on your Computer and navigate to chrome://inspect
There, you should see your phone listed. Now select the Button "port forwarding" and a popup will ... well ... pop up. There you enter in the left field named 'Port' some Port - 8080 works fine for me.
This is a listening port that will be on the phone. That means after you set the port forwarding up, you can open the Url localhost://8080 on your phone (in chrome) to navigate to your website. Your website can you specify in the right field named 'ip and Port'. For the Chrome Extension "Chrome Dev Editor" I enter http://192.168.0.6:51792/which is the ip, port and path on my server.
Chrome Dev Editor tells you what you can Enter there when you right-click your main.dart and select deploy to phone.
select "Done" and navigate to the URI with your phone - that would be localhost:8080/MyNewDartTry/web/index.htmlif you followed my example. But I believe you could also enter in the port-forwarding popup the whole address and then only open localhost:8080 on your phone.
The localhost:8080 is mapped to the link you entered.
As soon as you close Chrome on either your Desktop or your phone, the port-forward will be stopped.
With the emulator
Start your emulator
find your server's port. e.g. 54321
Open the browser in your emulator and enter 10.0.2.2:54321/MyNewDartTry/web/index.html(or whatever follows after your slashes, but make sure the IP is 10.0.2.2 - that refers to your computer on which the emulator runs
Hope this helps anybody
EDIT:
If chrome does not find your device even though the phone has also opened chrome and you followed all the steps, consider Emmanuel Malacarne's answer.
C:\Users\YOUR_USERNAME\AppData\Local\Android\sdk\platform-tools && C:
& adb.exe kill-server & adb.exe start-server" The directory depends on
your installation of your ADT.

Using Google Chrome Dev tools on Android (emulator)

I need to debug CSS for some site running on the device under Android (in the common REPL mode). As I know it is possible to connect the device with the desktop via USB cable to do that. But the problem is I have no such a device (with Android). I have the Android emulator (Andy) but it seems that chrome installed on it has no dev tools at all.
So is it possible to solve the problem without physical Android device?
UPD==================
Once again:
The point is I have no any Android device. I have an emulator for it only (Andy Android emulator).
Navigate to chrome://inspect/#devices on your chrome browser.
From there, you should see a list of attached devices (including emulators, not sure about Andy), but if it is possible, that's where you would find it.
Adding to Josh's answer, I've had to:
Navigate to chrome://inspect/#devices on my machine.
Open Chrome in Andy.
List devices with adb devices.
Andy finally shows up in Chrome's devices list.
In this context, "phone" is your emulator.
First you must enable debugging on your phone:
Settings > About Phone > Build number > Tap it 7 times to become developer;
then:
Settings > Developer Options > USB Debugging.
Then navigate to chrome://inspect/#devices. You should find the open tab on your phone there.

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