@echo off
set JAVA_HOME=D:\qclaw file\jdk-17.0.12+7
set ANDROID_HOME=D:\qclaw file\android-sdk
set ANDROID_SDK_ROOT=D:\qclaw file\android-sdk
set PATH=%JAVA_HOME%\bin;%PATH%

cd /d "C:\Users\Administrator\.qclaw\workspace\SafeCheckIn"

echo Cleaning all caches...
rmdir /s /q .gradle 2>nul
rmdir /s /q app\build 2>nul
rmdir /s /q build 2>nul

echo.
echo Building APK with updated dependencies...
call gradlew.bat assembleDebug --refresh-dependencies --stacktrace

if %ERRORLEVEL% == 0 (
    echo.
    echo ========================================
    echo Build successful!
    echo APK location: app\build\outputs\apk\debug\app-debug.apk
    echo ========================================
) else (
    echo.
    echo ========================================
    echo Build failed. Check the error messages above.
    echo ========================================
)

pause