Debugging!!! Logcat!!! IMPORTANT

8 views
Skip to first unread message

Rajeev

unread,
Dec 30, 2012, 8:37:26 AM12/30/12
to winter-training...@googlegroups.com
Attention Everybody!!

This is the moment you were waiting for!!!
Ever wondered why I take a lot of time to debug in the class but 
very quickly debug at the room...
Thats because I use Logcat..

WHY DID I HIDE IT TILL NOW:
And why didn't I use it in class...because I wanted all of you to 
Try to program without errors..
Solve your errors by being a compiler...
Solve your errors by careful observation...

And I think, by now you know what and why you are coding..
Had I told about this on the first day, you would have just used logcat everywhere 
without even know what you are learning....
That would just make everybody hit-and-trialers....

After all these line, I hope you understand why I didnt reveal logcats usage in the beginning.

Now, HOW TO DEBUG???

1) System.out.println(String)
Prints out the string onto the logcat with the 
Tag - System.out and color - green

2) Log.d(TAG, Debug String)
Prints out the string onto the logcat with the 
Tag - TAG and color - blue

3) Log.e(TAG, Error String)
Prints out the string onto the logcat with the 
Tag - TAG and color - red

4) Log.w(TAG, Warning String)
Prints out the string onto the logcat with the 
Tag - TAG and color - orange

Others are not required but if you are interested find them at LOG Functions

NOTE:
For debugging, you should not use "Run As" but rather use "Debug As".

Rajeev

unread,
Dec 30, 2012, 8:39:27 AM12/30/12
to winter-training...@googlegroups.com
Sample Code:

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Testing System.out
System.out.println("System.out is working");
//Testing Log
Log.d("DEBUG", "Log.d is working");
Log.e("ERROR", "Log.e is working");
Log.w("WARNING", "Log.w is working");
}
Reply all
Reply to author
Forward
0 new messages