Console of my Android Studio does not print the log message
Asked Answered
S

2

5

I created a Hello, World project in Android Studio to test using System.out.println(). I believe the log message should be printed in the console, but it wasn't. Im using Android Studio AI-130.737825 with JRE:1.7.0_25. The test code follows:

package com.example.consoletest;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    System.out.println("please print me in the console");
    setContentView(R.layout.activity_main);

}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}
Sickle answered 25/8, 2013 at 9:34 Comment(2)
"As I know the log message should be printed in the contolse, but it didn't" -- On Eclipse, log messages are shown in the LogCat view, and I would expect IDEA/Android Studio to behave similarly.Isreal
You would be better to use Log.v(TAG, String) to send messages to LogCat. developer.android.com/reference/android/util/Log.htmlUlund
A
7

The console is not "connected" to the running app because it is run on a different system (be it an emulator, or physical device). The only "connected" part in Android Studio is the LogCat, which can be accessed using the Android tab at the bottom of the IDE.

You should rather print output to LogCat using the Log.* methods, which provides a lot more control and information, in almost the same simplistic way. Additionally, the logcat can be filtered to find exactly what you want.

Alti answered 25/8, 2013 at 14:46 Comment(1)
how can i see exceptions and error generated by application ??Bacciferous
S
0

As @free3om hinted at, Log.* can be used to print out many different outputs to the Logcat. If you want to see just errors, you can use Log.e(String s1, String s2) to see what and where something went wrong. Here's a link to the doc's for Log. http://developer.android.com/reference/android/util/Log.html

Straw answered 2/6, 2015 at 23:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.