Android: How can I print a variable on eclipse console?
I wanted to print the value of a variable on the console for my debugging purpose, but System.out.println
doesn't work.
System.out.println
and Log.d
both go to LogCat, not the Console.
Window->Show View->Other…->Android->LogCat
I'm new to Android development and I do this:
1) Create a class:
import android.util.Log; public final class Debug{ private Debug (){} public static void out (Object msg){ Log.i ("info", msg.toString ()); } }
When you finish the project delete the class.
2) To print a message to the LogCat write:
Debug.out ("something");
3) Create a filter in the LogCat and write "info" in the input "by Log Tag". All your messages will be written here. :)
Tip: Create another filter to filter all errors to debug easily.
Writing the followin code to print anything on LogCat works perfectly fine!!
int score=0;
score++;
System.out.println(score);
prints score on LogCat.Try this