You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
slms/scripts/run_android.bat

154 lines
3.0 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

@echo off
chcp 65001 >nul
echo ========================================
echo SLMS Android Application
echo ========================================
echo.
set ANDROID_HOME=D:\development\Android
set JAVA_HOME=E:\2025-2026\GitAIOps\jdk
set PATH=%JAVA_HOME%\bin;%ANDROID_HOME%\platform-tools;%ANDROID_HOME%\emulator;%PATH%
echo 检查 Android 设备连接...
adb devices
echo.
echo 选择操作:
echo 1. 构建 APK
echo 2. 安装 APK
echo 3. 启动应用
echo 4. 构建并安装
echo 5. 完整流程(构建+安装+启动)
echo 6. 启动模拟器
echo 7. 卸载应用
echo 0. 退出
echo.
set /p choice=请输入选项 (0-7):
if "%choice%"=="1" goto build
if "%choice%"=="2" goto install
if "%choice%"=="3" goto launch
if "%choice%"=="4" goto build_install
if "%choice%"=="5" goto full
if "%choice%"=="6" goto emulator
if "%choice%"=="7" goto uninstall
if "%choice%"=="0" goto end
goto end
:build
echo.
echo 正在构建 APK...
call gradlew assembleDebug
if %errorlevel% neq 0 (
echo 构建失败!
pause
exit /b 1
)
echo ✓ APK 构建成功
echo APK 位置: android\build\outputs\apk\debug\SLMS-debug.apk
goto end
:install
echo.
echo 正在安装 APK...
adb install -r android\build\outputs\apk\debug\SLMS-debug.apk
if %errorlevel% neq 0 (
echo 安装失败!
pause
exit /b 1
)
echo ✓ APK 安装成功
goto end
:launch
echo.
echo 正在启动应用...
adb shell am start -n com.smartlibrary/.android.MainActivity
if %errorlevel% neq 0 (
echo 启动失败!
pause
exit /b 1
)
echo ✓ 应用已启动
goto end
:build_install
echo.
echo 正在构建并安装...
call gradlew assembleDebug
if %errorlevel% neq 0 (
echo 构建失败!
pause
exit /b 1
)
adb install -r android\build\outputs\apk\debug\SLMS-debug.apk
if %errorlevel% neq 0 (
echo 安装失败!
pause
exit /b 1
)
echo ✓ 构建并安装成功
goto end
:full
echo.
echo 正在执行完整流程...
call gradlew assembleDebug
if %errorlevel% neq 0 (
echo 构建失败!
pause
exit /b 1
)
echo ✓ 构建成功
adb install -r android\build\outputs\apk\debug\SLMS-debug.apk
if %errorlevel% neq 0 (
echo 安装失败!
pause
exit /b 1
)
echo ✓ 安装成功
adb shell am start -n com.smartlibrary/.android.MainActivity
if %errorlevel% neq 0 (
echo 启动失败!
pause
exit /b 1
)
echo ✓ 应用已启动
echo.
echo ========================================
echo 完整流程执行成功!
echo ========================================
goto end
:emulator
echo.
echo 正在启动模拟器...
echo 可用的模拟器:
emulator -list-avds
echo.
set /p avd_name=请输入模拟器名称(默认: pixel_5_-_api_34:
if "%avd_name%"=="" set avd_name=pixel_5_-_api_34
start emulator -avd %avd_name%
echo ✓ 模拟器正在启动...
echo 请等待模拟器完全启动后再进行其他操作
goto end
:uninstall
echo.
echo 正在卸载应用...
adb uninstall com.smartlibrary
if %errorlevel% neq 0 (
echo 卸载失败!应用可能未安装
pause
exit /b 1
)
echo ✓ 应用已卸载
goto end
:end
echo.
pause