破晓 发表于 2016-2-23 21:30:29

ANE原生代码的调试(安卓)

<span style="color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px; line-height: 28px;">忙了一天终于有空继续这篇教程了。</span><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;">ANE的原生代码的调试其实在Adobe的官网有介绍的,但是同样很含糊,我摸索了一段时间现在记录下我的心得。</div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;">首先你得安装Eclipse,然后你得启动Eclipse</div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"><br></div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"><div></div><div><br></div>&nbsp;然后选择DDMS界面。</div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"><span style="line-height: 24px; color: rgb(51, 51, 51); font-family: arial, 宋体, sans-serif; font-size: 14px; text-indent: 2em;">百度百科:</span></div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"><span style="text-indent: 2em;">&nbsp;</span><span style="line-height: 24px; color: rgb(51, 51, 51); font-family: arial, 宋体, sans-serif; font-size: 14px; text-indent: 2em;">DDMS 的全称是Dalvik Debug Monitor Service,是 Android 开发环境中的Dalvik</span><a target="_blank" rel="nofollow" href="http://baike.baidu.com/view/1132.htm" style="color: rgb(19, 110, 194); line-height: 24px; text-decoration: none; font-family: arial, 宋体, sans-serif; font-size: 14px; text-indent: 2em;">虚拟机</a><span style="line-height: 24px; color: rgb(51, 51, 51); font-family: arial, 宋体, sans-serif; font-size: 14px; text-indent: 2em;">调试监控服务。</span></div><div style="line-height: 24px; color: rgb(51, 51, 51); margin-bottom: 5px; text-indent: 2em; font-family: arial, 宋体, sans-serif;">它为我们提供例如:为测试设备截屏,针对特定的进程查看正在运行的线程以及堆信息、<a target="_blank" rel="nofollow" href="http://baike.baidu.com/view/4504801.htm" style="color: rgb(19, 110, 194); line-height: 24.5px; text-decoration: none;">Logcat</a>、广播状态信息、模拟电话呼叫、接收SMS、虚拟地理坐标等等。<span style="line-height: 28px; font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, 宋体; font-size: 16px;">&nbsp;</span></div><div style="line-height: 24px; color: rgb(51, 51, 51); margin-bottom: 5px; text-indent: 2em; font-family: arial, 宋体, sans-serif;"><span style="line-height: 28px; font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, 宋体; font-size: 16px;">我们使用DDMS工具就可以查看运行在手机中的程序的状态,打印出他们的日志,当然前提条件就是这个程序一定要标明为debug。</span></div><div style="line-height: 28px; font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px; color: rgb(51, 51, 51); margin-bottom: 5px; text-indent: 2em;">使用FlashBuilder编译AIR,尽管你选择的是debug模式(如图)</div><div style="line-height: 28px; font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px; color: rgb(51, 51, 51); margin-bottom: 5px; text-indent: 2em;"><br></div><div style="line-height: 28px; font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px; color: rgb(51, 51, 51); margin-bottom: 5px; text-indent: 2em;"><div><br></div>&nbsp;</div><div style="line-height: 28px; font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px; color: rgb(51, 51, 51); margin-bottom: 5px; text-indent: 2em;"><br></div><span style="color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px; line-height: 28px;">&nbsp;你依旧在DDMS,Devices上看不到你的程序。不知道是flashbuilder初心大意还是什么的,官方说明上没有明确的解释我们该怎么设置安卓的debug模式。</span><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"><span style="white-space: pre;">        </span>那么怎么设置安卓平台的Debug模式呢,其实很简单。</div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;">打开你src目录下的GameMain-app.xml然后在安卓配置说明那儿加上下图红框部分。</div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"><br></div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"><div></div><div><br></div><div>这样我们的程序就被打上了“debug”标签。</div><div>重新启动flashbuilder的debug,等待手机上程序的运行,然后我们就能在DDMS中发现我们的程序了。</div><div><br></div><div><div></div><div><br></div>&nbsp;</div>&nbsp;是不是很激动~如是乎很多人激动的就点击了那绿色的调试按钮,出现对话框的一瞬间一颗心就沉了下来!</div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"><br></div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"></div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"><br></div><span style="color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px; line-height: 28px;">&nbsp;不要激动,这是正常的,因为我们毕竟不是一个“正常”的应用程序,那么怎么做呢?</span><div><span style="color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px; line-height: 28px;">我们需要添加一个特别的调试侦听!</span><div><font color="#8a8679" face="Hiragino Sans GB W3, Hiragino Sans GB, Arial, Helvetica, simsun, u5b8bu4f53"><span style="font-size: 16px; line-height: 28px;"><br></span></font><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"><div></div><div><br></div>&nbsp;记下上图中红框中的数字“8601”这是我们添加调试侦听的端口。</div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;">然后点击debug-DebugConfigurations,打开调试配置面板!</div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"><br></div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"></div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"><br></div><span style="color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px; line-height: 28px;">&nbsp;注意下图的红框地方</span></div><div><font color="#8a8679" face="Hiragino Sans GB W3, Hiragino Sans GB, Arial, Helvetica, simsun, u5b8bu4f53"><span style="font-size: 16px; line-height: 28px;"><br></span></font><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"><div><div></div>&nbsp;</div>&nbsp;选择对应的ANE项目,填写好刚才获得的端口。</div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;">然后点击Debug按钮。</div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;">这时候你会发现程序左边的调试图标亮了。</div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"><br></div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"><div></div><div><br></div>&nbsp;debug也正确的跳转到你的ANE项目中了~骚年们开始你们的ANE原生调试之旅了~尽情的打断点,单步调试吧。</div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;">还等什么,下图是一个调试成功的截图!</div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"><br></div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"><div></div>&nbsp;</div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;"><br></div><div style="line-height: 28px; color: rgb(138, 134, 121); font-family: 'Hiragino Sans GB W3', 'Hiragino Sans GB', Arial, Helvetica, simsun, u5b8bu4f53; font-size: 16px;">本文来自:http://tmtbe.blog.163.com/blog/static/3965819420144128244510/</div><p></p></div></div>
页: [1]
查看完整版本: ANE原生代码的调试(安卓)