Debugging on Device Tips and Tricks

Hey Folks,
Discovered something really cool and I thought I would share. I was having problems with my app while running on my Android device- but it worked fine using the Corona Simulator. So, I wanted to see what was happening on the device. After a bit of investigation, I came up with the secret recipe:

Note: this requires that you install the Android SDK with adb

  • Keep your device plugged in to the USB port on your Windows PC
  • In Windows, bring up a command window
  • Type this command:

adb logcat Corona:V *:S

A little explanation of how this works:
This displays all of the Corona print commands in your code while running on the device. This filters out everything else- and there is a lot of other stuff that comes across when you use adb logcat. The V stands for Verbose and the S stands for Silent. All Corona print commands are given the tag “Corona.”

Now, all I have to do is debug my app. Yay!

terminal window command window android debugging [import]uid: 104085 topic_id: 29618 reply_id: 329618[/import]

Wow, awesome tip, @michael714! I had trouble isolating anything that shows up on adb logcat when I was working with Android build. This is great to know. Thank you for sharing!

Edit: I assume the command will work on Mac/terminal too – except that I may need to typ dot slash, like so ./adb logcat Corona:V *:S

Naomi [import]uid: 67217 topic_id: 29618 reply_id: 118907[/import]

Thank you. You helped me a lot. [import]uid: 138389 topic_id: 29618 reply_id: 118959[/import]

this is great, but I have a problem. I have the device connected to the USB port, but when I run “adb logcat Corona: V *: S”,  I get the message ‘Waiting for device’

please help me!! What I’m doing wrong??

@antonio.capel, one of my device also started showing “Waiting for device” – and I don’t understand why it started doing it.  It used to print fine without a problem.  And then one day it stopped.  It’s extremely annoying.  I googled and looked and looked, but I have not found a solution to my problem…  If anyone knows how to fix it, I’d love to hear about it too.

Naomi

thank you Naomi. 

I tested on 2 devices (a tablet and a mobile samsumg) and the same result :frowning:

Is your device in developer mode?

Sometimes the adb server gets confused and you need to shut it down, or unplug and replug your device in.

OMG, Rob, it suddenly started working.  Okay, here’s the thing.  I have not looked at Android version for the past few days, so I had the device turned off.  I just turned it back on, tethered it… and now it’s printing.  When it wasn’t working, I’m pretty sure I turned the device off and on, and did all sorts of things to get it recognized, but it never did.  I don’t understand why it needed a few days of rest.  I wonder if rebooting my Mac also helped (which I didn’t do when I was searching for the solution.)  Who knows.

@antonio.capel, if tablet & mobile samsung used to print fine with adb logcat, maybe what you need to do is turn them off , turn off the computer, and restart all over.  If they never worked, then you do want to make sure they are in developer mode.  If your tablet is one of the Nexus models, you might want to look at this too:

http://dottech.org/87439/how-to-unlock-usb-debugging-mode-on-android-4-2-jelly-bean-and-higher-guide/

Naomi

hi rob and noemi,

yes my device is in developer mode, well,I just put the option USB Debugging mode on in my tablet, I have to do something else?

I’ve also installed Android Debug Bridge ( android SDK Tools, android sdk platform tools and google USB Driver)

I’ve also rebooted the devices, but nothing…only  ‘Waiting for device’

One question , when put adb logcat Corona:V *:S, 'Corona ’  is the aplication that is listening?  have to put the name of my game? 

Thanks you for your help 

Hey, @antonio.capel, are you on Mac or Windows?

On Mac, I launch terminal app, and then change directory to: … /androidsdk/platform-tools (where adb resides)

And then I type ./adb logcat Corona:V *:S

That’s all I do – this is assuming the device is in developer/debug mode.

By the way, just in case, did you reboot your Mac/PC after you tried and failed and after you installed everything you need, and after you set your device to developer/debug mode?  Or at least restarted the terminal app?  I don’t know what made mine work again, but after I gave up on it and ignored the device, at Rob’s prompt, I thought, maybe, somehow, the device’s developer mode got turned off so I checked, and since it still looked like everything was in order, I gave it one more shot at logcat – that’s when it magically started working again.  I did nothing to make the device work with adb after it stopped working nice.  So… only reason that I can think of is either shutting-down and restarting the terminal app, or shutting down the Mac and restarting it.  At least it seems that way in my case anyhow.

Naomi

adb  launches a small server on your service that handles the communications between adb and the device.

You can do:

adb devices

to get a list of connected devices. 

Thanks guys,  I just tried it and the debugging on my old Droid is working fine.

this is great, but I have a problem. I have the device connected to the USB port, but when I run “adb logcat Corona: V *: S”,  I get the message ‘Waiting for device’

please help me!! What I’m doing wrong??

@antonio.capel, one of my device also started showing “Waiting for device” – and I don’t understand why it started doing it.  It used to print fine without a problem.  And then one day it stopped.  It’s extremely annoying.  I googled and looked and looked, but I have not found a solution to my problem…  If anyone knows how to fix it, I’d love to hear about it too.

Naomi

thank you Naomi. 

I tested on 2 devices (a tablet and a mobile samsumg) and the same result :frowning:

Is your device in developer mode?

Sometimes the adb server gets confused and you need to shut it down, or unplug and replug your device in.

OMG, Rob, it suddenly started working.  Okay, here’s the thing.  I have not looked at Android version for the past few days, so I had the device turned off.  I just turned it back on, tethered it… and now it’s printing.  When it wasn’t working, I’m pretty sure I turned the device off and on, and did all sorts of things to get it recognized, but it never did.  I don’t understand why it needed a few days of rest.  I wonder if rebooting my Mac also helped (which I didn’t do when I was searching for the solution.)  Who knows.

@antonio.capel, if tablet & mobile samsung used to print fine with adb logcat, maybe what you need to do is turn them off , turn off the computer, and restart all over.  If they never worked, then you do want to make sure they are in developer mode.  If your tablet is one of the Nexus models, you might want to look at this too:

http://dottech.org/87439/how-to-unlock-usb-debugging-mode-on-android-4-2-jelly-bean-and-higher-guide/

Naomi

hi rob and noemi,

yes my device is in developer mode, well,I just put the option USB Debugging mode on in my tablet, I have to do something else?

I’ve also installed Android Debug Bridge ( android SDK Tools, android sdk platform tools and google USB Driver)

I’ve also rebooted the devices, but nothing…only  ‘Waiting for device’

One question , when put adb logcat Corona:V *:S, 'Corona ’  is the aplication that is listening?  have to put the name of my game? 

Thanks you for your help 

Hey, @antonio.capel, are you on Mac or Windows?

On Mac, I launch terminal app, and then change directory to: … /androidsdk/platform-tools (where adb resides)

And then I type ./adb logcat Corona:V *:S

That’s all I do – this is assuming the device is in developer/debug mode.

By the way, just in case, did you reboot your Mac/PC after you tried and failed and after you installed everything you need, and after you set your device to developer/debug mode?  Or at least restarted the terminal app?  I don’t know what made mine work again, but after I gave up on it and ignored the device, at Rob’s prompt, I thought, maybe, somehow, the device’s developer mode got turned off so I checked, and since it still looked like everything was in order, I gave it one more shot at logcat – that’s when it magically started working again.  I did nothing to make the device work with adb after it stopped working nice.  So… only reason that I can think of is either shutting-down and restarting the terminal app, or shutting down the Mac and restarting it.  At least it seems that way in my case anyhow.

Naomi

adb  launches a small server on your service that handles the communications between adb and the device.

You can do:

adb devices

to get a list of connected devices.