fix(android): 修复批处理文件中文乱码问题

修复内容:
1. 添加 chcp 65001 设置UTF-8编码(支持中文)
2. 改用全英文输出(避免不同CMD编码导致的乱码)

现在在任何Windows CMD环境都能正确显示。

问题原因:
- Windows CMD默认使用GBK编码
- 批处理文件使用UTF-8编码保存
- 导致中文字符显示为乱码

解决方案:
- chcp 65001 切换到UTF-8编码页(静默执行)
- 使用英文输出确保兼容性

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
hailin 2026-01-26 23:53:25 -08:00
parent 20b5593a0b
commit c2ee9b6daf
1 changed files with 36 additions and 41 deletions

View File

@ -1,96 +1,91 @@
@echo off @echo off
chcp 65001 >nul 2>&1
setlocal enabledelayedexpansion setlocal enabledelayedexpansion
echo ======================================== echo ========================================
echo 编译、安装、启动、调试 一键脚本 echo Build - Install - Launch - Debug
echo ======================================== echo ========================================
echo. echo.
:: 设置颜色(如果支持) :: Step 1: Build Debug APK
set "GREEN=[92m" echo [1/5] Building Debug APK...
set "RED=[91m"
set "YELLOW=[93m"
set "RESET=[0m"
:: 步骤1: 编译 Debug APK
echo %YELLOW%[1/5] 正在编译 Debug APK...%RESET%
call gradlew.bat assembleDebug --no-daemon call gradlew.bat assembleDebug --no-daemon
if %errorlevel% neq 0 ( if %errorlevel% neq 0 (
echo %RED%[ERROR] 编译失败!%RESET% echo [ERROR] Build failed!
pause pause
exit /b 1 exit /b 1
) )
echo %GREEN%[SUCCESS] 编译完成!%RESET% echo [SUCCESS] Build completed!
echo. echo.
:: 步骤2: 检查设备连接 :: Step 2: Check device connection
echo %YELLOW%[2/5] 检查设备连接...%RESET% echo [2/5] Checking device connection...
adb devices adb devices
adb devices | find "device" | find /v "List" >nul adb devices | find "device" | find /v "List" >nul
if %errorlevel% neq 0 ( if %errorlevel% neq 0 (
echo %RED%[ERROR] 未检测到设备请连接手机并启用USB调试。%RESET% echo [ERROR] No device detected! Please connect your phone and enable USB debugging.
pause pause
exit /b 1 exit /b 1
) )
echo %GREEN%[SUCCESS] 设备已连接!%RESET% echo [SUCCESS] Device connected!
echo. echo.
:: 步骤3: 卸载旧版本(避免签名冲突) :: Step 3: Uninstall old version (to avoid signature conflicts)
echo %YELLOW%[3/5] 卸载旧版本(如果存在)...%RESET% echo [3/5] Uninstalling old version (if exists)...
adb uninstall com.durian.tssparty 2>nul adb uninstall com.durian.tssparty 2>nul
echo %GREEN%完成!%RESET% echo Done!
echo. echo.
:: 步骤4: 安装 APK :: Step 4: Install APK
echo %YELLOW%[4/5] 正在安装 APK...%RESET% echo [4/5] Installing APK...
adb install app\build\outputs\apk\debug\app-debug.apk adb install app\build\outputs\apk\debug\app-debug.apk
if %errorlevel% neq 0 ( if %errorlevel% neq 0 (
echo %RED%[ERROR] 安装失败!%RESET% echo [ERROR] Installation failed!
pause pause
exit /b 1 exit /b 1
) )
echo %GREEN%[SUCCESS] 安装完成!%RESET% echo [SUCCESS] Installation completed!
echo. echo.
:: 步骤5: 启动应用 :: Step 5: Launch app
echo %YELLOW%[5/5] 正在启动应用...%RESET% echo [5/5] Launching app...
adb shell am start -n com.durian.tssparty/.MainActivity adb shell am start -n com.durian.tssparty/.MainActivity
if %errorlevel% neq 0 ( if %errorlevel% neq 0 (
echo %RED%[ERROR] 启动失败!%RESET% echo [ERROR] Launch failed!
pause pause
exit /b 1 exit /b 1
) )
echo %GREEN%[SUCCESS] 应用已启动!%RESET% echo [SUCCESS] App launched!
echo. echo.
:: 清除旧日志 :: Clear old logs
echo %YELLOW%清除旧日志...%RESET% echo Clearing old logs...
adb logcat -c adb logcat -c
echo. echo.
:: 提示用户 :: Show instructions
echo ======================================== echo ========================================
echo 应用已成功启动! echo App successfully launched!
echo ======================================== echo ========================================
echo. echo.
echo %GREEN%现在开始监控日志...%RESET% echo Starting log monitoring...
echo. echo.
echo 关键日志标签: echo Key log tags:
echo - MainViewModel (ViewModel ) echo - MainViewModel (ViewModel layer)
echo - TssRepository (Repository ) echo - TssRepository (Repository layer)
echo - GrpcClient (网络通信) echo - GrpcClient (Network communication)
echo - TssNativeBridge (TSS 原生库) echo - TssNativeBridge (TSS native library)
echo - AndroidRuntime (崩溃日志) echo - AndroidRuntime (Crash logs)
echo. echo.
echo %YELLOW%【提示】按 Ctrl+C 可停止日志监控%RESET% echo Press Ctrl+C to stop log monitoring
echo. echo.
timeout /t 2 /nobreak >nul timeout /t 2 /nobreak >nul
:: 开始监控日志(带关键词高亮) :: Start monitoring logs
adb logcat -v time MainViewModel:D TssRepository:D GrpcClient:D TssNativeBridge:D AndroidRuntime:E *:S adb logcat -v time MainViewModel:D TssRepository:D GrpcClient:D TssNativeBridge:D AndroidRuntime:E *:S
:: 如果用户停止了日志监控 :: If user stops log monitoring
echo. echo.
echo %YELLOW%日志监控已停止。%RESET% echo Log monitoring stopped.
echo. echo.
pause pause