How to print to the console in Android Studio?

2019-01-10 06:13发布

I just downloaded Android Studio for Linux from: http://developer.android.com/sdk/installing/studio.html

I'm wondering how to print to the console?

Neither System.out.print(...) nor Log.e(...) from android.util.Log seem to work.

5条回答
放我归山
2楼-- · 2019-01-10 06:39

If your app is launched from device, not IDE, you can do later in menu: Run - Attach Debugger to Android Process.

This can be useful when debugging notifications on closed application.

查看更多
该账号已被封号
3楼-- · 2019-01-10 06:46

If the above solutions don't work, you can always see the output in the Android Monitor.


android studio screen shot


Make sure to set your filter to Show only selected application or create a custom filter.

enter image description here

查看更多
该账号已被封号
4楼-- · 2019-01-10 06:46

You can see the println statements in Run window in Android Studio. so you can see the prinln statements in that window.

See detailed answer with screenshot here

查看更多
时光不老,我们不散
5楼-- · 2019-01-10 06:58

Run your application in debug mode by clicking on

enter image description here

in the upper menu of Android Studio.

In the bottom status bar, click 5: Debug button, next to the 4: Run button.

Now you should select the Logcat console.

In search box, you can type the tag of your message, and your message should appear, like in the following picture (where the tag is CREATION):

enter image description here

Check this article for more information.

查看更多
Root(大扎)
6楼-- · 2019-01-10 06:58

Android has its own method of printing messages (called logs) to the console, known as the LogCat.

When you want to print something to the LogCat, you use a Log object, and specify the category of message.

The main options are:

  • DEBUG: Log.d
  • ERROR: Log.e
  • INFO: Log.i
  • VERBOSE: Log.v
  • WARN: Log.w

You print a message by using a Log statement in your code, like the following example:

Log.d("myTag", "This is my message");

Within Android Studio, you can search for log messages labelled myTag to easily find the message in the LogCat. You can also choose to filter logs by category, such as "Debug" or "Warn".

查看更多
登录 后发表回答