通过Wi-Fi调试Android应用

#!/bin/bash
   
#Modify this with your IP range
MY_IP_RANGE="192\.168\.1\.102"

#You usually wouldn't have to modify this
PORT_BASE=5555

#List the devices on the screen for your viewing pleasure
adb devices
echo

#Find USB devices only (no emulators, genymotion or connected devices
declare -a deviceArray=(`adb devices -l | grep -v emulator | grep -v vbox | grep -v "${MY_IP_RANGE}" | grep " device " | awk '{print $1}'`)  

echo "found ${#deviceArray[@]} device(s)"
echo

for index in ${!deviceArray[*]}
do
echo "finding IP address for device ${deviceArray[index]}"
IP_ADDRESS=$(adb -s ${deviceArray[index]} shell ifconfig wlan0 | awk '{print $3}')

echo "IP address found : $IP_ADDRESS "

echo "Connecting..."
adb -s ${deviceArray[index]} tcpip $(($PORT_BASE + $index))
adb -s ${deviceArray[index]} connect "$IP_ADDRESS:$(($PORT_BASE + $index))"

echo
echo
done

adb devices -l
#exit

然后直接把文件拖动终端中去。。

直接把 aa.sh 拖入到终端里面。 

注意事项: 

如果 没有成功报出问题::  

Permission denied。就是没有权限。 

解决办法: 

修改该文件adbwifi.sh  的权限 :使用命令: 

chmod 777 adbwifi.sh

然后还是没有找到设备。。

这时就要配置adb环境了。。

一、终端中输入 cd ~

二、输入touch .bash_profile 回车

三、输入open -e .bash_profile

回车后会在TextEdit中打开这个文件(如果未配置过环境变量,应该是个空白文件)。

export PATH=${PATH}:/Users/techstan/Downloads/adt-bundle-mac-x86_64-20140702/sdk/platform-tools

//这是我的路径,根据自己的路径修改

保存,退出TextEdit(一定要退出哦)。关闭终端并推出。

然后再输入终端输入adb测试。。

没有问题直接再执行adbwifi.sh文件

sh /Users/techstan/Desktop/adbwifi.sh  




转载于:https://my.oschina.net/techstan/blog/392360

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值