您的位置:首页 > 移动开发

用adb操作apk和app的脚本

2016-05-13 00:29 597 查看

.cmd

echo off
cls

rem ------------------------------------------------------------
rem 用adb.exe操作apk(安装,卸载), 操作app(启动,停止)
rem ------------------------------------------------------------

rem ------------------------------------------------------------
rem 设备名称
rem ------------------------------------------------------------
set DEVICE_NAME=emulator-5554

rem ------------------------------------------------------------
rem .apk名称
rem ------------------------------------------------------------
set APK_NAME=MyWeChat.apk

rem ------------------------------------------------------------
rem 包名
rem ------------------------------------------------------------
set PACKAGE_NAME=com.test.ls.mywechat

rem ------------------------------------------------------------
rem activity名称
rem ------------------------------------------------------------
set ACTIVITY_NAME=.LsMainActivity

rem ------------------------------------------------------------
rem 包名和activity名称的组合
rem ------------------------------------------------------------
set PACKAGE_AND_ACTIVITY_NAME=%PACKAGE_NAME%/%ACTIVITY_NAME%

echo "------------------------------------------------------------"
echo ">> install app"
echo "------------------------------------------------------------"
adb -s %DEVICE_NAME% install %APK_NAME%
echo "------------------------------------------------------------"
echo "<< install app"
echo "------------------------------------------------------------"

echo press any key to run app
pause

echo "------------------------------------------------------------"
echo ">> run app"
echo "------------------------------------------------------------"
adb -s %DEVICE_NAME% shell am start -n %PACKAGE_AND_ACTIVITY_NAME%
echo "------------------------------------------------------------"
echo "<< run app"
echo "------------------------------------------------------------"

echo press any key to stop app
pause

echo "------------------------------------------------------------"
echo ">> stop app"
echo "------------------------------------------------------------"
adb -s %DEVICE_NAME% shell pm disable %PACKAGE_NAME%
adb -s %DEVICE_NAME% shell pm enable %PACKAGE_NAME%
echo "------------------------------------------------------------"
echo "<< stop app"
echo "------------------------------------------------------------"

echo "------------------------------------------------------------"
echo press any key to uninstall app
echo "------------------------------------------------------------"
pause

adb -s %DEVICE_NAME% uninstall %PACKAGE_NAME%
echo "------------------------------------------------------------"
echo uninstall over, press any key to quit
echo "------------------------------------------------------------"

pause
echo on


run result

"------------------------------------------------------------"
">> install app"
"------------------------------------------------------------"
2468 KB/s (1248976 bytes in 0.494s)
pkg: /data/local/tmp/MyWeChat.apk
Success
rm failed for -f, Read-only file system
"------------------------------------------------------------"
"<< install app"
"------------------------------------------------------------"
press any key to run app
请按任意键继续. . .
"------------------------------------------------------------"
">> run app"
"------------------------------------------------------------"
Starting: Intent { cmp=com.test.ls.mywechat/.LsMainActivity }
"------------------------------------------------------------"
"<< run app"
"------------------------------------------------------------"
press any key to stop app
请按任意键继续. . .
"------------------------------------------------------------"
">> stop app"
"------------------------------------------------------------"
Package com.test.ls.mywechat new state: disabled
Package com.test.ls.mywechat new state: enabled
"------------------------------------------------------------"
"<< stop app"
"------------------------------------------------------------"
"------------------------------------------------------------"
press any key to uninstall app
"------------------------------------------------------------"
请按任意键继续. . .
Success
"------------------------------------------------------------"
uninstall over, press any key to quit
"------------------------------------------------------------"
请按任意键继续. . .
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: