您的位置:首页 > 移动开发 > Android开发

Maven开发Android指南 5 调试

2017-07-20 10:46 267 查看
对于一个使用Maven的Android应用,调试看起来是个大问题,没有"Debug as Android application"怎么办?总不能一直用logcat(Log.v(TAG,…)吧。
 
如果阅读了《Maven开发Android指南 4 与Eclipse整合(m2e-android
)》,那么这就不是问题了。
 
m2e-android很智能的将 Android Developer Tools (ADT)和 Maven Android Plugin结合在一起,细心的读者可以看到,左上角项目图标上面有一个M和A,分别代表着Maven和Android。
 


正如上篇提到到的,可以"Run as Android application",那么当然可以"Debug as Android application"
 
 
 
但是还是有些读者不满足,就是不喜欢"Debug as Android application",那么DDMS将是你的选择。(需要安装m2e-android)



 
通过命令部署Android应用

cd HelloM2EAndroid
mvn android:emulator-start
mvn clean package android:deploy
 
打开Eclipse中的DDMS,选择对应的应用,点击绿色的小甲壳虫,它将会帮你抓住所有断点。
 
 
 
 
 
 
 
 
名词解释:
logcat是Android中一个命令行工具,可以用于得到程序的log信息。
The Android logging system provides a mechanism for collecting and
viewing system debug output. Logs from various applications and portions of the
system are collected in a series of circular buffers, which then can be viewed
and filtered by the logcat command. You can use logcat from an ADB shell to
view the log messages
DDMS的全称是Dalvik Debug Monitor Service,是 Android 开发环境中的Dalvik虚拟机调试监控服务。它为我们提供例如:为测试设备截屏,针对特定的进程查看正在运行的线程以及堆信息、Logcat、广播状态信息、模拟电话呼叫、接收SMS、虚拟地理坐标等等。
Android ships with a debugging tool called the Dalvik Debug Monitor
Server (DDMS), which provides port-forwarding services, screen capture on the
device, thread and heap information on the device, logcat, process, and radio
state information, incoming call and SMS spoofing, location data spoofing, and
more
 
参考:
http://code.google.com/p/maven-android-plugin/wiki/Debug
http://baike.baidu.com/view/4504801.htm
http://baike.baidu.com/view/2688850.htm
http://developer.android.com/tools/help/logcat.html
http://developer.android.com/tools/debugging/ddms.html





大小: 29.6 KB

查看图片附件
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: