ITeye博客

Android应用程序的调试

ielad · 2011-03-29 11:26 · 移动开发 · Markdown

1、DDMS的启动

启动eclipse后,单击Eclipse的右上角的“Open Prespective”,选择“DDMS”。若没有就选择“Other...”,从弹出的对话框中选择DDMS。

2、Devices面板

 

3、Emulator Control面板

 

4、信息输出面板

Logcat输出应用程序的运行信息,分为调试信息(debug),警告信息(warn),错误信息(error),普通信息(info)及冗余信息(verbose)。

 |— 自定义输出标签:

5、DDMS中的日志输出

       log类中的方法及说明

package cl.ad;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
/**打印出不同的log信息 */
public class Main extends Activity {
 
    String TAG = "mylog";         // 定义日志标签
    
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Log.v(TAG, "this is a verbose message.");    	   //输出冗余信息  黑色
        Log.d(TAG, "this is a debug message.");   	  //输出调试信息 蓝色 
        Log.i(TAG, "this is a info message.");    	  //输出普通信息 绿色 
        Log.w(TAG, "this is a warning message."); 	  //输出警告信息 黄色
        Log.e(TAG, "this is a error message.");  	 //输出错误信息 红色
    }
} 

 

DDMS可以根据标签对应用程序进行过滤。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。