Debugging an Android WebView from the PC via adb - android

I have just recently started android development. I'm actually building a Web application that runs off an Android WebView. So, I'd like to know if there is any way to debug the web application (js,css,html) from the PC via the ADB or anything. I Googled it and got options but none have an extensive debugging facility like firebug. So, any ideas would be greatly appreciated. Thanks in advance.

Since Android 4.2 (if i'm not mistaking the version) you can:
turn on development mode on your phone
connect it via USB cable to your PC
make sure to "Trust this computer" on the tablet/phone
go to chrome://inspect on your PC in Google Chrome, you should see your device and the pages that are open on it.
clicking one of the links will pop up an inspector for the respective page on the device, complete with inspect element, console, networking and everything else the Chrome inspector has.
This is how i debug my app on a Nexus 7 tablet. If your device is running an older version of Android, there's little you can do apart from console.log's and tediously finding them through an adb logcat.

Related

How to enable usb debugging on android with black screen?

I was trying to enable USB debugging option on my Samsung Galaxy J1 Ace (SM-J110H) handset. As you already know that the screen is black/dead but except that the cellphone is working just fine. Somehow I managed to enable the USB debugging option by using an OTG cable and a USB keyboard(and off-course a lot of screenshots). But still unable to authorize USB debugging for my pc as I'm not able to click always allow from this computer.
So how do I allow/ authorize USB debugging from my pc? TIA
Ι would write it here as a comment, because answer is not based on facts, however on black screens I try to remember the basic buttons and can use some of my phones even blindfolded.
However when I was having a similar problem, I used a tool called ADB that made it possible to access some of my Lenovo A390's shell features via Windows CMD and managed to turn on USB-Debugging and even download some backup files from a password-holder app I used in that time.
https://www.androidphonesoft.com/resources/enable-usb-debugging-android-broken-screen.html
There was also a stack exchange topic that helped me run through the process.
https://android.stackexchange.com/questions/112040/how-to-enable-usb-debugging-in-android-if-forgotten-pattern-for-screen-unlock
Hope that helped.
Have two phones. The one with the dead screen and a working one. Download any app that can mirror an Android to another. Use the mouse to download it. Install it in the two phones. You can download apps like airdoid. Create account on the good phone, then login into the same account on both phones. U will be able to control the other phone with the working phone so that you accept the debugging prompt when it appears

AppBuilder doesn't recognise Android devices

I'm trying to develop an app on Telerik AppBuilder and want to run it on physical devices. Even if I connect the devices with USB, AppBuilder doesn't recognise and the devices don't show up. I have enabled 'USB debugging', chosen 'MTP' as USB connection mode. I tired restarting everything, still the same issue. Is there something to do that I'm missing?
But when I connect my iPhone, it appears on devices list. However, I can't run and debug since I have no certificate from Apple.
So, what can be the problem for detecting the device? Thanks.
It could be a driver issue with your device (does it show up on your PC when you connect it?). You can check out other instructions in the docs here.

Remote Debugging Chrome on Android issue

I am have issues using the remote debugging feature of the Chrome Developers tools with my Android device (LG Nitro running Android version 4.0.4). It was working perfectly several days ago but now my device never appears on the about:inspect page.
I have followed and carefully considered these instructions including the troubleshooting tips. I have also searched for the answer to my problem but have not been able to find anything that works.
I am using Chrome version 35.0.1916.141 on my Android device and version 35.0.1916.114 on my PC (Windows 7). Neither says any updates are available.
Please note:
I have enabled debugging on my Android device and the small bug icon appears in the menu bar at the top of the screen when the USB cable is connected.
I have installed the necessary drivers for my phone on my PC.
Chrome is open on both devices
"Discover USB devices" is checked
I have tried restarting both the computer and my phone several times
The only thing I have changed on my computer since the last time it was working was to download 64-bit Java. Could this have any effect? If anyone has any input or ideas, it would be much appreciated!
Sounds like you may have gotten lucky. Next time this happens, try this:
1) Unplug your device.
2) Revoke USB debugging in the Developer Tools.
3) In the command line:
adb kill-server
adb start-server
Plug in device and accept fingerprint.
Voila, it appears in Chrome again. I went through a lot of pain with random problems with my Galaxy S5 not showing up, I was pulling my hair out for hours trying to figure it out.
Update: After launching my Android application from Eclipse on my device, it suddenly showed up on the about:inspect page. I am not sure why it was not recognizing my phone before but it seems to be working now.

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...

Android development setup when using USB Host mode

I am a relatively new Android developer but have gotten pretty familiar with the SDK, using LogCat, etc. However, I'm now working on an app (for a Galaxy Tab 7-plus) that utilizes USB Host mode to talk to an external USB device and I've run into an issue.
My question is: What is an ideal environmental setup that will allow me to take advantage of all of the SDK tools (adb, debug, LogCat, DDMS, and so forth) when I am unable to be connected to my PC via USB (since the external USB device my tablet is talking to is using my tab's only USB port)?
Is there an emulator available somewhere (I've searched in vain) that will allow me to simulate USB Host mode using a USB port on my PC?
Do I need to go to some type of on-board logging app?
Is there some kind of 30-pin splitter available so I can connect to both the external device and my PC? (I'm guessing this is impossible, but I'm a hardware idiot... in addition to a run-of-the-mill idiot).
Thanks in advance for your help!
-KR
As I posted in the comments, If the tablet is rooted you can use AdbWireless (Application on the Market)
This can also be done without rooting. Google/Android officially supports this, as described at the bottom of this page:
http://developer.android.com/guide/topics/usb/index.html
But AdbWireless is easier if you are rooted.

Categories

Resources