这个我绝对hold不住了,以前一直想在vim里面为android项目打断点。不过最后只能作到输出用于打断点的命令,而没法和jdb结合起来运行。不过昨天无聊去stackoverflow上问了一下以后,竟然找到了解决办法。这个世界太美好了!java
如今的缺陷是没法debug inner class,等何时蛋疼了再写个正则匹配下内部类。不过如今这种程度应该能解决不少问题了。android
下面上渣代码,请尽情喷。shell
vim script:vim
function! DebugContacts() let ori_str = expand("%:r") let start_index = matchend(ori_str, "src\.") let debug_path = strpart(ori_str, start_index, strlen(ori_str)) let debug_path = substitute(debug_path, "/", ".", "g") let debug_path .= ":".line(".") echo expand(debug_path) exec "!echo stop at ".debug_path exec "!{ echo "." stop at \"".debug_path."\"; cat; } | debug_contacts" endf noremap <leader>dd :call DebugContacts()<cr>
debug_contacts是写在shell脚本里面的tcp
function debug_contacts() { local pid=$(adb shell ps | grep android.process.acore | awk '{print $1}') adb forward tcp:7777 jdwp:$pid jdb -attach 7777 -sourcepath $CONTACTS/src }
大概是这样子了,我先爽去了。debug