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。
![](http://dl.iteye.com/upload/attachment/0078/2463/b06c5da7-1893-3800-9d97-91fb26a0f1ba.png)
正如上篇提到到的,可以"Run as Android application",那么当然可以"Debug as Android application"
但是还是有些读者不满足,就是不喜欢"Debug as Android application",那么DDMS将是你的选择。(需要安装m2e-android)
![](http://dl.iteye.com/upload/attachment/0078/2582/3e100e4a-4dec-3699-b2b2-2da1c6de7eea.png)
通过命令部署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
![](http://dl2.iteye.com/upload/attachment/0078/2582/3e100e4a-4dec-3699-b2b2-2da1c6de7eea-thumb.png)
大小: 29.6 KB
查看图片附件
如果阅读了《Maven开发Android指南 4 与Eclipse整合(m2e-android
)》,那么这就不是问题了。
m2e-android很智能的将 Android Developer Tools (ADT)和 Maven Android Plugin结合在一起,细心的读者可以看到,左上角项目图标上面有一个M和A,分别代表着Maven和Android。
![](http://dl.iteye.com/upload/attachment/0078/2463/b06c5da7-1893-3800-9d97-91fb26a0f1ba.png)
正如上篇提到到的,可以"Run as Android application",那么当然可以"Debug as Android application"
但是还是有些读者不满足,就是不喜欢"Debug as Android application",那么DDMS将是你的选择。(需要安装m2e-android)
![](http://dl.iteye.com/upload/attachment/0078/2582/3e100e4a-4dec-3699-b2b2-2da1c6de7eea.png)
通过命令部署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
![](http://dl2.iteye.com/upload/attachment/0078/2582/3e100e4a-4dec-3699-b2b2-2da1c6de7eea-thumb.png)
大小: 29.6 KB
查看图片附件
相关文章推荐
- Maven开发Android指南 3 使用Android Maven Archetypes 创建新项目
- Maven开发Android指南 4 与Eclipse整合(m2e-android )
- Eclipse maven android开发指南
- Maven开发Android指南 2 配置android-maven-plugin
- Maven开发Android指南 1 简介
- Maven开发Android指南
- Eclipse+php插件+Xdebug搭建PHP完美开发/调试环境指南
- Android开发入门(三)之调试工具adb,ddms
- Android开发指南-框架主题-意图和意图过滤器
- Android 程序的开发调试
- Android开发指南-框架主题-基础知识
- Android开发指南 2──用户界面
- Android开发指南-用户界面-对话框
- Android开发指南-框架主题-安全和许可
- Android开发指南-框架主题-数据存储
- Android开发指南-用户界面-菜单特性
- Android开发指南-用户界面-创建菜单
- Android入门开发指南之六 -- 指南:一个记事本应用程序
- Android开发指南-框架主题-资源和资产
- Android 入门开发指南之二 -- Eclipse环境下安装开发