@echo off
setlocal EnableExtensions DisableDelayedExpansion
chcp 437 >nul
cd /d "%~dp0"
title OK ITHAKI Android Studio Duplicate Fix V24753

echo ===============================================================
echo OK ITHAKI V24753 - ANDROID DUPLICATE RESOURCES FIX
echo ===============================================================
echo This script removes Android build caches and duplicate compressed assets.
echo Open this folder in Android Studio: android_studio\OK_ITHAKI_AUTO_APP
echo.

if exist ".gradle" rmdir /s /q ".gradle"
if exist "build" rmdir /s /q "build"
if exist "app\build" rmdir /s /q "app\build"
if exist "app\src\main\assets\index.js.gz" del /f /q "app\src\main\assets\index.js.gz"
for /r "app\src\main\assets" %%G in (*.gz) do del /f /q "%%G"

echo Clean complete.
echo.
if exist "gradlew.bat" (
  call gradlew.bat clean assembleDebug --no-build-cache
) else (
  echo Gradle wrapper not found. Use Android Studio: Build ^> Clean Project, then Rebuild Project.
)

echo.
echo If Android Studio still shows Duplicate resources:
echo 1. File ^> Invalidate Caches / Restart
echo 2. Open ONLY android_studio\OK_ITHAKI_AUTO_APP, not the outer ZIP folder
echo 3. Build ^> Clean Project, then Rebuild Project
echo.
pause
