image1 image2 image3

HELLO I'M NITENDRA THAKUR|WELCOME TO MY PERSONAL BLOG|I LOVE TO DO CREATIVE THINGS|I'M PROFESSIONAL ANDROID APPLICATION DEVELOPER

How to Debug Java code with logcat?

Debug Java code with logcat


Before continue on to show you tools to create Android Apps, We'll show you some tools for debugging and testing your Apps. One of the most important tools is called LogCat. 

This is a tool that is available when you use ADB The Android Debug Bridge to run Apps on emulators and devices. 

The LogCat tool receives messages from the Android run-time and from your app, and you can actually send you own messages. To find out whether LogCat is running, try running an app on an emulator or device.

The first time you run an application, you might see a dialog asking for permission to run LogCat. Always say yes. If LogCat is working, the LogCat view will show a series of messages. 

The tag will indicate the source of the message. For example the Android run time, and the Dalvik Virtual Machine are system level message sources. While the Activity Manager, the Package Manager And other manager tools are a part of the application framework.

One of the reasons LogCat is so important is that if you have a fatal error, that is a crash scenario, the details will be available through LogCat. 

Debugging in Android

Debugging allows you to debug a running program interactively while watching the source code and the variables during the execution.

By breakpoints in the source code you can  specify where the execution of the program should stop or not working . To stop the execution only if a field is read or modified, you can specify watchpoints .

Breakpoints and watchpoints can be summarized as stop points or break events to let us know how our program is running and what is the cause behind the failure.

Once the program is stopped you can investigate variables, change their content, etc.

Debug In Eclipse

Eclipse allows you to Debug your project as android application and find out or look over the source code and optimize that code as per the requirement. if you can face any kind of issues while running your application you can set an breakpoint within the suspected code.

to set breakpoints into your code right click on the left hand margin of your project and select the Toggle BreakPoint.



 Key bindings / shortcuts

F5         Executes the currently selected line and goes to the next line in your program , if                  selected line is a method call debugger steps into the associated code.

F6         It executes a method without stepping into it in the debugger.

F7         Finishes the execution og current call and returns to the caller of current method.

F8         It tell the eclipse debugger to resume the execution of program code till it didn't get                next breakpoint or watchpoint.

Share this:

CONVERSATION

0 comments:

Post a Comment