赞
踩
adb install [-lrtsdg] (file)
把包文件推送到设备上并安装。
-l 锁定应用
-r 替换已存在的应用
-t 允许安装测试包
-s 安装到sd卡中
-d 可以安装低版本安装包
-p 安装部分应用
-g 授权所有运行时权限
adb uninstall [-k] (package)
卸载设备上的应用包,-k表示保存数据和缓存目录。
adb_install.sh
#!/bin/bash echo $1 adb devices > devices.txt echo "开始读取设备" line_num=0 while read -r line do if [ $line_num != 0 ] && [ -n "$line" ]; then devices_info=`echo $line | cut -d " " -f 1` echo $devices_info adb -s $devices_info install -d -r $1 fi let line_num++ done < devices.txt rm -f devices.txt
./adb_install.sh apk路径.apk
You can use adb devices to get a list of connected devices and then run adb -s DEVICE_SERIAL_NUM install… for every device listed.
Something like (bash):
adb devices | tail -n +3 | cut -sf 1 -d " " | xargs -iX adb -s X install -r ...
Comments suggest this might work better for newer versions:
adb devices | tail -n +2 | cut -sf 1 | xargs -iX adb -s X install -r ...
For Mac OSX(not tested on Linux):
adb devices | tail -n +2 | cut -sf 1 | xargs -I {} adb -s {} install -r ...
可以使用下面的命令一次性安装多个apk:
adb install-multiple [-lrtsdpg] <file...>
- push this package file to the device and install it
(-l: forward lock application)
(-r: replace existing application)
(-t: allow test packages)
(-s: install application on sdcard)
(-d: allow version code downgrade (debuggable packages only))
(-p: partial application install)
(-g: grant all runtime permissions)
在一个固定路径(例如:D:\bat_helper )文件夹下创建 multi_install.bat, D:\AAAAPPPPPPPKKKKKKK 路径是我存放 apk 的路径:
adb devices | tail -n +2 | cut -sf 1 | xargs -iX adb -s X install -r -d D:\AAAAPPPPPPPKKKKKKK\%1
创建 multi_install_util.bat, 我这里一次装了三个包 demo, local, pro:
start multi_install.bat Demo-%1.apk
start multi_install.bat Local8000-%1.apk
start multi_install.bat Product-%1.apk
可以在任意目录下创建下面的 bat文件,之后直接打开使用即可,更新版本也只需改个版本号:
d:
cd d:\bat_helper\
multi_install_util.bat V1.3.5
随意找个地方,创建个 install_apk.bat
文件,修改内容为下:
@echo off
echo --------------------------------------------------------
echo start install %1
echo -----小米-------
adb -s 29e63c30 install -r %1
echo -----大三星-------
adb -s 42f7c21301979f2f install -r %1
echo --------------------------------------------------------
pause
设备可使用命令查看:
adb devices
然后将这个 install_apk.bat 所在的文件夹路径加到环境变量里,每次打开cmd 输入 install_apk + apk路径即可。
还可以在桌面上创建个 .bat 文件,内容:
@echo off
echo --------------------------------------------------------
install_apk D:\AAAAPPPPPPPKKKKKKK\Local.apk
pause
只要打开 bat 就可以自动安装给设备, 但要指定文件路径和apk名字。
创建uninstall_apk.bat
:
@echo off
echo --------------------------------------------------------
echo start uninstall %1
adb -s 9c10a497 uninstall %1
adb -s VS9804G5c12ef38 uninstall %1
adb -s 29e63c30 uninstall %1
adb -s ZY222WLGV4 uninstall %1
adb -s 42f7c21301979f2f uninstall %1
adb -s 4530c0df uninstall %1
echo --------------------------------------------------------
pause
uninstall_apk + 包名
卸载。
基础版每次添加新设备后,都要在文件里写入新的设备信息,比较麻烦。所以做了下修改,使用adb命令拿到 devices 信息后,再安装这些设备上,立马高大上了一大截,线性安装apk的bat 文件代码如下:
@echo off echo -------------------------------------------------------- echo Get devices adb devices > devices.txt cat devices.txt echo -------------------------------------------------------- echo start install %1 for /f "skip=1 tokens=1 delims= " %%i in (devices.txt) do ( adb -s %%i install -r %1 ) del devices.txt echo -------------------------------------------------------- pause
%%i 是 devices 信息, %1 是传入的apk绝对路径。
并发安装需要创建一个新的bat 文件,用来分离安装命令,我起的名字是adb_install.bat:
echo start install apk to %1
adb -s %1 install -r %2
并发安装apk的bat命令是:
@echo off echo -------------------------------------------------------- echo Get devices adb devices > devices.txt cat devices.txt echo -------------------------------------------------------- echo start install %1 for /f "skip=1 tokens=1 delims= " %%i in (devices.txt) do ( start adb_install %%i %1 ) del devices.txt echo -------------------------------------------------------- pause
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。