console.log and HTC devices

4,404 views
Skip to first unread message

paulb

unread,
Apr 29, 2011, 12:40:48 PM4/29/11
to phon...@googlegroups.com
Does anyone know the right trick to show console.log output in adb logcat for HTC devices from PhoneGap apps? I have no problem with the emulator, Nexus One or Motorola Droid. See also the unanswered http://stackoverflow.com/questions/5538516/javascript-console-log-on-htc-android-devices-and-adb-logcat

Michael Herger

unread,
Apr 29, 2011, 4:33:36 PM4/29/11
to phon...@googlegroups.com

This report is about running console.log() in the browser. I've never had problems using it in PhoneGap.

--

Michael

paulb

unread,
Apr 29, 2011, 5:09:36 PM4/29/11
to phon...@googlegroups.com
I haven't had a problem using console.log in PhoneGap either on other devices, but it doesn't work for me on the HTC Evo.

Paul

zb

unread,
Apr 29, 2011, 6:16:33 PM4/29/11
to phonegap
Hello,

In eclipse click Window -> Show View -> other..

in the pop up window. Expand Android folder select LogCat and press
ok.

Logcat tab should show up in the bottom window frame.

-zb

On Apr 29, 12:40 pm, paulb <paul.beuster...@gmail.com> wrote:
> Does anyone know the right trick to show console.log output in adb logcat
> for HTC devices from PhoneGap apps? I have no problem with the emulator,
> Nexus One or Motorola Droid. See also the unansweredhttp://stackoverflow.com/questions/5538516/javascript-console-log-on-...

Patrick Mueller

unread,
Apr 30, 2011, 9:22:00 AM4/30/11
to phon...@googlegroups.com
On 4/29/11 5:09 PM, paulb wrote:
> I haven't had a problem using console.log in PhoneGap either on other
> devices, but it doesn't work for me on the HTC Evo.

If you happen to be using weinre, it intercepts console.log() requests,
so you won't see them in the usual place. It should only be doing this
while the debugger client is connected to a target, so you be able see
console output somewhere.

BTW, I'm planning on fixing my console.log() support to pass through the
messages to the original console, instead of overriding them.

--
Patrick Mueller - http://muellerware.org

paulb

unread,
Apr 30, 2011, 4:17:10 PM4/30/11
to phon...@googlegroups.com
I did some more investigation today in the Java debugger. 

On the Nexus One, the following method in DroidGap gets called on a JavaScript console.log :

     // console.log in api level 7: http://developer.android.com/guide/developing/debug-tasks.html

    @Override

    public void onConsoleMessage(String message, int lineNumber, String sourceID)

    {       

    // This is a kludgy hack!!!!

    Log.d(TAG, sourceID + ": Line " + Integer.toString(lineNumber) + " : " + message);

    }


On the HTC Evo, the breakpoint in onConsoleMessage never gets hit. 


Also, I found further evidence on stackoverflow that there is a general problem with console.log, Android 2.2 and HTC devices.


For now, I'll stick to the Nexus One or Droid when I need console.log. 

paulb

unread,
Apr 30, 2011, 5:06:31 PM4/30/11
to phon...@googlegroups.com
Patrick,

I wasn't running weinre, but am now and it's a good workaround for the HTC Evo problem. All of the console.log messages come to the weinre console.

BTW, weinre is a great tool! It is cool to inspect and control my device from my laptop.

Any hope of adding JavaScript run control?

Cheers,
Paul
Reply all
Reply to author
Forward
0 new messages