我的Android Studio的控制台不会打印日志消息

lu *_*uan 5 console android println android-studio

我在Android Studio中创建了一个Hello,World项目来测试使用System.out.println().我相信日志消息应该在控制台中打印,但事实并非如此.我使用Android Studio AI-130.737825和JRE:1.7.0_25.测试代码如下:

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;
}

}
Run Code Online (Sandbox Code Playgroud)

fre*_*dom 7

控制台未与正在运行的应用程序"连接",因为它在不同的系统(无论是模拟器还是物理设备)上运行.Android Studio中唯一的"连接"部分是LogCat,可以使用IDE底部的Android选项卡进行访问.

您应该使用Log.*方法将输出打印到LogCat ,这些方法以几乎相同的简单方式提供更多控制和信息.此外,可以过滤logcat以准确找到您想要的内容.