摘要:前言当前连着多个安卓设备时,当超出了所支持的设备数,步骤如下列出你当前的设备列表,然后拷贝你要安装的设备使用来进行安装效果图快捷命令这个必须要参考底下命令的下达获取安卓设备数量没有设备的总行数第一行第二行空获取自定义格式设备
前言
当前PC连着多个安卓设备时,当超出了 adb 所支持的设备数,步骤如下:
adb devices 列出你当前的设备列表,然后拷贝你要安装的设备Device Id; 使用 adb -s deviceId
install .... 来进行 APK 安装
error: more than one device/emulator adb: error: failed to get feature set: more than one device/emulator - waiting for device - error: more than one device/emulator效果图
#adb 快捷命令 function adbConnect(){ echo "Your connect is 192.168.$1" # 这个 $1 必须要参考底下命令的下达 adb connect 192.168.$1 } function adbDisconnect(){ adb disconnect } function adbShell(){ adb shell } function devices(){ adb devices } # 获取安卓设备数量 function getAdbDevicesCount(){ no_dev=2 #没有设备的总行数 第一行: List of devices attached 第二行 空 line="`adb devices | wc -l`" # echo "$line" echo $(($line-$no_dev)) } #获取自定义格式设备名称 参数1: adb devices 设备ID index function getFmtDeviceName(){ if [ -n "$1" ]; then line=$1 let "line++" #跳过1行 deviceId="`adb devices | sed -n "${line}p" | awk "{printf $1" "}" `" # name="`adb devices | sed -n "2p;${line}p" | awk "{printf NR ". " $1" "}" `" #简单列出设备ID manufacturer="`adb -s $deviceId shell getprop ro.product.manufacturer`" model="`adb -s $deviceId shell getprop ro.product.model`" version="`adb -s $deviceId shell getprop ro.build.version.release`" sdk="`adb -s $deviceId shell getprop ro.build.version.sdk`" name="${manufacturer} ${model} Android ${version} API ${sdk} Serial: ${deviceId} " # 去除某些设备后面携带回车符 name=`echo ${name} | tr -d " "` echo ${name} else echo "requires an argument" fi } # 列出所有设备 function listFmtDevices(){ count=`getAdbDevicesCount` index=1 while(( $index<=count )) do name=`getFmtDeviceName ${index}` echo "${index}. ${name} " let "index++" done } # 获取设备ID 参数1: adb devices 设备ID index function getFmtDeviceId(){ if [ -n "$1" ]; then line=$1 let "line++" #跳过1行 deviceId="`adb devices | sed -n "${line}p" | awk "{printf $1" "}" `" # 去除某些设备后面携带回车符 deviceId=`echo ${deviceId} | tr -d " "` echo ${deviceId} else echo "requires an argument" fi } # 安装apk function apk(){ if [ -n "$1" ]; then count=`getAdbDevicesCount` one_dev=1 if [ $count -eq $one_dev ] then # 单设备 name=`getFmtDeviceName 1` echo "install apk to devices: ${name}" adb install -r $1 elif [ $count -gt $one_dev ] then # 多设备 if [ -n "$2" ]; then # 带设备index index=$2 deviceId=`getFmtDeviceId ${index}` name=`getFmtDeviceName ${index}` echo "install apk to devices: $name" adb -s $deviceId install -r $1 else # 带apk文件路径 echo "install apk to which devices?" listFmtDevices read -p "Enter: " index apk $1 $index fi else echo "no devices" fi else echo "apk requires an apkPath argument" fi } # 卸载apk function uapk(){ if [ -n "$1" ]; then count=`getAdbDevicesCount` one_dev=1 if [ $count -eq $one_dev ] then # 单设备 name=`getFmtDeviceName 1` echo "uninstall apk on $name" adb uninstall $1 elif [ $count -gt $one_dev ] then # 多设备 if [ -n "$2" ]; then # 带设备index index=$2 deviceId=`getFmtDeviceId ${index}` name=`getFmtDeviceName ${index}` echo "uninstall apk on devices: $name" adb -s $deviceId uninstall $1 else # 带apk文件路径 echo "uninstall apk on which devices?" listFmtDevices read -p "Enter: " index uapk $1 $index fi else echo "no devices" fi else echo "uapk requires an pkg argument" fi } # 进入adb shell 环境 function as(){ count=`getAdbDevicesCount` one_dev=1 if [ $count -eq $one_dev ] then # 单设备 name=`getFmtDeviceName 1` echo "${name} Last login: `date`" adb shell elif [ $count -gt $one_dev ] then # 多设备 if [ -n "$1" ]; then # 带设备index index=$1 deviceId=`getFmtDeviceId ${index}` name=`getFmtDeviceName ${index}` echo "${name} Last login: `date`" adb -s $deviceId shell else # 不带设备index echo "enter shell which devices?" listFmtDevices read -p "Enter: " index as $index fi else echo "no devices" fi }
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/15022.html
摘要:第四个提示不可截屏。代码设置不允许截屏在项目里面,通过设置可以让界面不允许执行截屏操作。这边实际测试验证了,只要禁止截屏的界面可见,就算它的回调了,也是不可以截屏的。本文公众号「AndroidTraveler」首发。 背景 在实际的应用场景中,Android 手机的截屏其实是很普遍的。 比如说 PPT 演示,比如说技术博客图文并茂讲解。 因此懂得 Android 手机截屏的各种操作就显得尤为...
摘要:第四个提示不可截屏。代码设置不允许截屏在项目里面,通过设置可以让界面不允许执行截屏操作。这边实际测试验证了,只要禁止截屏的界面可见,就算它的回调了,也是不可以截屏的。本文公众号「AndroidTraveler」首发。 背景 在实际的应用场景中,Android 手机的截屏其实是很普遍的。 比如说 PPT 演示,比如说技术博客图文并茂讲解。 因此懂得 Android 手机截屏的各种操作就显得尤为...
摘要:为了在电脑上玩手机游戏,国内推出了很多安卓模拟器,夜神海马等等。我们也可以用他们来做安卓开发,相对或者自带的模拟器而言,国产模拟器的优点是安装简单一步到位运行流畅缺点是安卓版本固定不能改。 为了在电脑上玩手机游戏,国内推出了很多安卓模拟器,mumu、夜神、itools、海马等等。我们也可以用他们来做安卓开发,相对genymotion或者android studio自带的模拟器而言,国产模拟...
摘要:注意阅读本文需要一台已经的安卓手机说明系统手机小米已抓包工具微信版本现象安卓手机无法通过代理抓包请求,我前天年月日用的不知道为什么能抓到,昨天手残更新到就不行了。 注意:阅读本文需要一台已经root的安卓手机! 说明 系统:MacOS 10.13.6 手机:小米6(已root) 抓包工具:Charles 微信版本:7.0.4 现象 安卓手机无法通过Charles代理抓包https请求,...
阅读 863·2021-11-18 13:23
阅读 3417·2021-11-15 11:37
阅读 571·2021-11-08 13:16
阅读 619·2021-10-11 10:58
阅读 3323·2021-09-22 15:26
阅读 1432·2021-09-08 10:42
阅读 1610·2021-09-04 16:45
阅读 1349·2021-09-04 16:45