1.前言
做android开发的同学应该会每天push 各种库到手机中, 为了尽量方便,我写了下面的bat脚本提供给大家使用。
2.环境
windows
3.脚本内容
adb wait-for-device
@echo off
::UTF-8编码
chcp 65001 >NUL
::自行修改
PATH_NAME=\库所在的绝对路径
set "FILE_NAMES=libxxxxxx.so"
set "PUSH_PATH=/vendor/lib64/"
adb devices
call :adb_root_remount
echo.
::是否重启,要看前面是否已经remount成功
echo 是否需要重启?
echo 1. 按1执行重启
echo 2. 按2继续push
echo.
choice /c 12 /n
echo.
if %errorlevel% equ 1 (
echo 正在重启
adb reboot
adb wait-for-device
echo 重启完毕
call :adb_root_remount
timeout /t 5 > nul
call :adb_push_files
) else if %errorlevel% equ 2 (
call :adb_push_files
)
::杀进程,这里也可以直接改成adb reboot重启手机
adb shell pkill camera*
echo.
echo ===== push 完成,按任意键结束终端 =====
pause >nul
exit /b
:adb_root_remount
adb root
adb shell setenforce 0
adb remount
exit /b
:adb_push_files
@echo off
for %%i in (%FILE_NAMES%) do (
setlocal enabledelayedexpansion
set "FILE_NAME=%%i"
set "FULL_PATH=!PATH_NAME!\!FILE_NAME!"
echo 完整的文件路径是:!FULL_PATH!
echo(
adb push "!FULL_PATH!" !PUSH_PATH!
echo(
endlocal
)
exit /b