---
title: "Android应用程序的调试"
author: "ielad"
date: "2011-03-29T11:26:38Z"
tags: []
categories: ["移动开发"]
slug: "android"
draft: false
lastmod: "2011-03-30T08:54:30Z"
id: 978364
url: "https://ielad.iteye.com/blog/978364"
---

1、DDMS的启动

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

2、Devices面板

 

3、Emulator Control面板

 

4、信息输出面板

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

 |— 自定义输出标签：

![](http://dl.iteye.com/upload/attachment/449638/aae2f750-a954-335b-9cfe-189533357055.jpg)

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可以根据标签对应用程序进行过滤。