# SkatePro Academy - APK Build Guide

## BEFORE YOU START - IMPORTANT

You need to change ONE LINE in the code before building:

### Step 0: Set Your Server URL

Open this file:
```
android/app/src/main/assets/public/assets/index-XXXX.js
```

Find this line:
```
const SERVER_URL = 'https://YOUR-SERVER-URL.COM/api';
```

Change to YOUR actual website:
```
const SERVER_URL = 'https://sandboxinnovation.com/api';
```

(Replace with your actual domain where PHP files are uploaded)

---

## OPTION A: Build APK in Android Studio (Recommended)

### Prerequisites:
- Download Android Studio: https://developer.android.com/studio
- Install Java 17 or higher

### Steps:

1. **Download the android folder** from this project

2. **Open Android Studio**

3. **Click "Open" and select the `android/` folder**

   ```
   File > Open > Select: SkatePro-Android/android
   ```

4. **Wait for Gradle sync** (first time takes 5-10 minutes)

5. **Build APK:**
   ```
   Build > Build Bundle(s) / APK(s) > Build APK(s)
   ```

6. **Get your APK:**
   ```
   Build > Show in Explorer
   ```
   Location: `android/app/build/outputs/apk/debug/app-debug.apk`

7. **Install on phone:**
   - Transfer APK to phone
   - Tap to install (allow "Unknown Sources" if asked)

---

## OPTION B: Build using Command Line (Advanced)

### Prerequisites:
- Install Android SDK Command Line Tools
- Set environment variables

### Commands:
```bash
# 1. Navigate to android folder
cd android

# 2. Make gradlew executable (Mac/Linux)
chmod +x gradlew

# 3. Build debug APK
./gradlew assembleDebug

# 4. Find your APK
# Location: android/app/build/outputs/apk/debug/app-debug.apk
```

---

## HOW THE APP WORKS

```
+-------------+      INTERNET       +----------------+
|   PHONE     |  =================> |  YOUR SERVER   |
|  (APK App)  |                     |  (PHP + MySQL) |
+-------------+                     +----------------+
|             |                     |                |
| UI loads    |--- API calls ----->| /api/auth.php  |
| locally     |   (login check)     | /api/students  |
| (fast!)     |                     | /api/timing    |
|             |<-- JSON response ---| /api/fees      |
|             |                     | etc.           |
+-------------+                     +----------------+
```

**The app bundles the UI (buttons, screens, colors) locally.**
**Only data (student names, fees, timing) comes from your server.**

This means:
- App opens FAST (UI is on phone)
- Data is always current (comes from server)
- Works on any phone with internet
- Same database for website + app

---

## TROUBLESHOOTING

### "App shows blank screen"
- Check SERVER_URL is correct
- Make sure your server is online
- Check internet permission in AndroidManifest.xml

### "Cannot connect to server"
- Add this to `android/app/src/main/AndroidManifest.xml` inside `<application>`:
```xml
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"
```

### "Login not working"
- Verify PHP files are uploaded to `/api/` on server
- Check database is connected
- Test website in browser first

---

## WHAT FILES YOU NEED

From this project, you only need the `android/` folder:
```
android/
  app/
    src/
      main/
        assets/public/     <-- All UI files (HTML, CSS, JS)
        java/              <-- Native Android code
        res/               <-- App icons, splash screen
        AndroidManifest.xml
    build.gradle
  build.gradle
  gradle/
  gradlew
  settings.gradle
```

---

## NEXT: Publish to Play Store

After APK is working:
1. Build release APK: `./gradlew assembleRelease`
2. Sign with keystore
3. Upload to Google Play Console
4. Publish!

---

**Questions? The main thing is: Set your SERVER_URL, open in Android Studio, click Build!**
