3

Does someone know how should I have my System.out.println() displayed in the logcat.I tried in the command line to browse my tools directory form C-Program Files-Android-android-sdk...tools,but when I use the ADB log-cat it says that ADB is not recognized....any command I use with adb it says unrecognised! I'm using eclipse.Thanks

UPDATE 1: Log.d(String, String)-a simple message and is not displayed neither LOGCAT or DDMS!!!! UPDATE 2: I've used ADB log-cat command after I browsed my platform-tools directory.In the cmd I have the Log.d() lines displayed but in my my Log-cat view from eclipse still nothing.Maybe because I have two emulators running and I don't know how to select the right one!!!!

Inzimam Tariq IT
  • 6,548
  • 8
  • 42
  • 69
adrian
  • 4,574
  • 17
  • 68
  • 119

6 Answers6

4

There is no console to send the messages to so the System.out.println messages get lost. Use Android's Log class

Why doesn't "System.out.println" work in Android?

Logcat not displaying my log calls

Community
  • 1
  • 1
Priyank
  • 10,503
  • 2
  • 27
  • 25
  • Check my EDITed answer with new link "Logcat not displaying my log calls." http://stackoverflow.com/questions/4228641/logcat-not-displaying-my-log-calls – Priyank Apr 19 '11 at 19:02
1

Don't use system.out.println, use the Log class instead.

Log.w("MyClassName", "This is a warning");

adb logcat is a way to view the logcat files. You need to locate the binary called 'adb' in order to use it. However, if you are using eclipse you can also just use the logcat view. It should show up if you switch to the DDMS perspective, or find it under Window -> Show view -> other.

Cheryl Simon
  • 46,552
  • 15
  • 93
  • 82
0

If you're used to using System.out.println("MY message HERE") in Java this is as close as I can get in Android.

Using Logcat from the command line:

  1. In your code define a global tag (for logcat):

    public static final String TAG = "MYTAG";
    
  2. Insert error message in your code:

    Log.v(TAG, "** I AM HERE **");
    
  3. From your command line search the device log file:

    adb logcat -s MYTAG
    

Note you can also send the results to a file:

adb logcat -s MYTAG > xyzFile.txt
Tom
  • 16,842
  • 17
  • 45
  • 54
  • I've changed your `Log -v (...)` to `Log.v(...)`, because I'm sure you meant this method: [Log#v(String, String)](http://developer.android.com/reference/android/util/Log.html#v%28java.lang.String,%20java.lang.String%29). – Tom Jan 30 '15 at 19:04
0

Probably what I'd recommend, is to use Toast. http://developer.android.com/guide/topics/ui/notifiers/toasts.html

It is somewhat an easier way to see you want to see through System.out.println().

Hope this might help someone. :)

Saim Mehmood
  • 783
  • 8
  • 14
0

adb is located in your SDK's platform-tools/ directory. You can also examine LogCat using DDMS or the DDMS perspective in Eclipse.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
0

I am not sure that I understand your question, but I think you should try looking for DDMS in Eclipse.

CoffeeRain
  • 4,460
  • 4
  • 31
  • 50
Divers
  • 9,531
  • 7
  • 45
  • 88