win10 中以開啓 linux子系統的方式使用 AndBug

1). 參考前面一篇博文在win10中安裝windows的 linux 子系統 (180M左右)

2). 在 linux 子系統中運行些指令

3). 修改一點點 andbug 源碼(python)


安裝 源碼管理、編譯器等相關的工具:

sudo su

apt-get install git

apt-get install gcc

apt-get install Python-dev python-pyrex


AndBug 源碼下載:
git clone https://github.com/anbc/AndBug/
在 /AndBug/lib/andbug/config.py 中修正 monitor_fun.conf 路徑


安裝 AndBug:

python setup.py install


測試運行 andbug

./andbug

若有顯示 andbug 的參數列表,說明安裝成功




至於  adb , 一定要確保 windows 本身的adb版本, 跟 linux 子系統中的 adb 版本是一致,

才能在 linux 子系統中用adb連接上手機~


        ADB 和 Fastboot for Windows
  https://dl.google.com/android/repository/platform-tools-latest-windows.zip

  ADB 和 Fastboot for Linux

  https://dl.google.com/android/repository/platform-tools-latest-linux.zip


都是最新版的 adb 1.0.39

若有其它版本的 adb 在運行,可以:

adb kill-server #把它關掉





網上有人說 andbug 在 windows 下的 linux  環境中不可用。

這是因爲 andbug 默認是使用 *nix localfilesystem 的方式來做 adb 端口轉發,

而 windows 中根本沒有辦法支持這種試, 所以只要改一點點 andbug 代碼,讓其使用 tcp 端口來做轉發就沒問題了。。。


修改如下:

文件: E:\Bash\AndBug\lib\andbug\proto.py

將 forward 函數那一段改成下面的即可!

def forward(pid, dev=None):
    'constructs an adb forward for the context to access the pid via jdwp'
    if dev:
        dev = andbug.util.find_dev(dev)
    pid = andbug.util.find_pid(pid)
    #temp = tempfile.mktemp() #創建一個臨時文件
    cmd = ('-s', dev) if dev else ()  #'-s', 'emulator-5554'
    #cmd += ('forward', 'localfilesystem:' + temp,  'jdwp:%s' % pid) #'-s', 'emulator-5554', 'forward', 'localfilesystem:/tmp/tmpSSCNAl', 'jdwp:843')
    cmd += ('forward', 'tcp:23946',  'jdwp:%s' % pid) #'-s', 'emulator-5554', 'forward', 'tcp:23946', 'jdwp:843')
    andbug.util.adb(*cmd)
    return 23946


修改完重新安裝:

sudo ./setup.py clean

sudo ./setup.py install





andbug 使用:

# export PATH="$PATH:/mnt/e/Bash/AndBug"

ln -s /mnt/e/Bash/platform-tools/adb /usr/bin/adb

./andbug shell -p 7052



應用斷住後查看變量:http://localhost:8080



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章