Dan
Dan

Reputation: 16236

Debug Android application on device without debugger

I am in a desperate situation.

I am developing an Android application using the ADT in Eclipse on Ubuntu 10.04 on a netbook.

Unfortunately the netbook is not powerful enough to run the Device Emulator (when I try there are always issues). Then, I tried to debug on-device, but unfortunately my phone (Pulse) seems to have some problem.

It seems I can't debug. I have already spent hours trying to get that working. And I can't afford to upgrade my netbook/mobile now.

The only thing I can do is developing on Eclipse and run the application on the phone.
Is there any way I can debug while the application is running on my phone? Can I create somewhere a log with errors/warnings and even some custom messages I put in the code?

What a situation.

Any help would be appreciated.

Thanks,
Dan

Upvotes: 1

Views: 7280

Answers (3)

Alex Jasmin
Alex Jasmin

Reputation: 39496

On device debugging should work. Make sure you have android:debuggable="true" in your application manifest. I previously had debugging issues that fixed themselves after rebooting the device.

Alternately, you can use the Log class to print out log messages. These can be seen by running adb logcat or in the logcat view of Eclipse.

Edit:

It seems that on some devices you have to run echo 1 > /sys/kernel/logger/log_main/enable from adb shell to enable logging.

Upvotes: 2

Octavian Helm
Octavian Helm

Reputation: 39604

I don't understand why you wouldn't be able to debug on the device. Just make sure your device is recognized by Ubuntu by following this article.

Upvotes: 0

Jean
Jean

Reputation: 10600

You can debug an android application directly through a tool named DDMS included in the SDK. With Eclipse the plugin intgrates everything for you: just create a breakpoint on the line you want to stop to by double-clicking in the margin, then hit the 'debug' button (the little bug at the top of the window). The program will start on the device and the device will display a message 'waiting for debugger to attach'. The message should disappear within a few seconds and will stop at the line you put the breakpoint on.

As for create logs, you can use the android.util.Log class:

import android.util.Log;
...
Log.e("MYAPPLICATION", "my message");

This should show in the "Logcat" view of eclipse.

Upvotes: 0

Related Questions