|
| 1 | +# 🌟 FULL GUIDE — Angular App → Android APK (with Live Updates via Vercel) |
| 2 | + |
| 3 | +--- |
| 4 | + |
| 5 | +## 🧱 **STEP 1: Prepare your Angular project** |
| 6 | + |
| 7 | +Open your project folder. |
| 8 | + |
| 9 | +Make sure it runs locally first: |
| 10 | + |
| 11 | +```bash |
| 12 | +ng serve |
| 13 | +``` |
| 14 | + |
| 15 | +If everything works, stop it and build for production: |
| 16 | + |
| 17 | +```bash |
| 18 | +ng build --configuration production |
| 19 | +``` |
| 20 | + |
| 21 | +After build, verify you have: |
| 22 | + |
| 23 | +``` |
| 24 | +dist/project-name/browser/index.html |
| 25 | +``` |
| 26 | + |
| 27 | +✅ This folder contains your compiled Angular app. |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## 🌐 **STEP 2: Host on Vercel (Auto Deploy from GitHub)** |
| 32 | + |
| 33 | +### 1️⃣ Push your code to GitHub |
| 34 | + |
| 35 | +If you haven’t already: |
| 36 | + |
| 37 | +```bash |
| 38 | +git init |
| 39 | +git add . |
| 40 | +git commit -m "Initial commit" |
| 41 | +git branch -M main |
| 42 | +git remote add origin https://github.com/<your-username>/<your-repo>.git |
| 43 | +git push -u origin main |
| 44 | +``` |
| 45 | + |
| 46 | +### 2️⃣ Go to [https://vercel.com](https://vercel.com) |
| 47 | + |
| 48 | +* Log in with **GitHub** |
| 49 | +* Click **“Add New Project”** |
| 50 | +* Select your **Angular repo** |
| 51 | + |
| 52 | +### 3️⃣ Configure Build Settings (important) |
| 53 | + |
| 54 | +| Setting | Value | |
| 55 | +| -------------------- | ------------------------------------- | |
| 56 | +| **Root Directory** | `./` | |
| 57 | +| **Build Command** | `ng build --configuration production` | |
| 58 | +| **Output Directory** | `dist/project-name/browser` | |
| 59 | + |
| 60 | +Then click **Deploy 🚀** |
| 61 | + |
| 62 | +### 4️⃣ Test your hosted app |
| 63 | + |
| 64 | +After build, open the URL Vercel gives you: |
| 65 | + |
| 66 | +``` |
| 67 | +https://project-name.vercel.app |
| 68 | +``` |
| 69 | + |
| 70 | +✅ Your Angular app is now live online! |
| 71 | +Each time you push to GitHub, Vercel **auto-updates** it. |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +## ⚙️ **STEP 3: Add Capacitor to wrap Angular into Android** |
| 76 | + |
| 77 | +In your Angular project folder: |
| 78 | + |
| 79 | +```bash |
| 80 | +npm install @capacitor/core @capacitor/cli |
| 81 | +npm install @capacitor/android |
| 82 | +npx cap init |
| 83 | +``` |
| 84 | + |
| 85 | +When asked: |
| 86 | + |
| 87 | +* **App name** → `App name` |
| 88 | +* **App ID** → `com.project-name.app` |
| 89 | + |
| 90 | +--- |
| 91 | + |
| 92 | +## 📱 **STEP 4: Add the Android platform** |
| 93 | + |
| 94 | +```bash |
| 95 | +npx cap add android |
| 96 | +``` |
| 97 | + |
| 98 | +This creates a folder: |
| 99 | + |
| 100 | +``` |
| 101 | +android/ |
| 102 | +``` |
| 103 | + |
| 104 | +That’s your native Android project (for Android Studio). |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +## 🌍 **STEP 5: Make the Android app load your live hosted version** |
| 109 | + |
| 110 | +Edit your file `capacitor.config.ts` like this: |
| 111 | + |
| 112 | +```ts |
| 113 | +import { CapacitorConfig } from '@capacitor/cli'; |
| 114 | + |
| 115 | +const config: CapacitorConfig = { |
| 116 | + appId: 'com.project-name.app', |
| 117 | + appName: 'App name', |
| 118 | + webDir: 'dist/project-name/browser', |
| 119 | + server: { |
| 120 | + url: 'https://project-name.vercel.app', // 👈 Your live Vercel URL |
| 121 | + cleartext: true |
| 122 | + } |
| 123 | +}; |
| 124 | + |
| 125 | +export default config; |
| 126 | +``` |
| 127 | + |
| 128 | +This makes your Android app load your **live site from Vercel** instead of local files. |
| 129 | + |
| 130 | +--- |
| 131 | + |
| 132 | +## 🔁 **STEP 6: Sync Capacitor changes** |
| 133 | + |
| 134 | +```bash |
| 135 | +npx cap sync |
| 136 | +``` |
| 137 | + |
| 138 | +--- |
| 139 | + |
| 140 | +## 🧩 **STEP 7: Open Android Studio** |
| 141 | + |
| 142 | +```bash |
| 143 | +npx cap open android |
| 144 | +``` |
| 145 | + |
| 146 | +Android Studio will open your native project. |
| 147 | + |
| 148 | +--- |
| 149 | + |
| 150 | +## ▶️ **STEP 8: Run the app** |
| 151 | + |
| 152 | +In Android Studio: |
| 153 | + |
| 154 | +1. Plug in your Android device (enable USB debugging) or start an emulator |
| 155 | +2. Click the **green ▶️ Run** button |
| 156 | + |
| 157 | +💥 Your Angular app will now run as a **native Android app**, loading data from your Vercel site. |
| 158 | + |
| 159 | +--- |
| 160 | + |
| 161 | +## 🔄 **STEP 9: Auto Updates (no new APKs needed)** |
| 162 | + |
| 163 | +Here’s the magic part 💫 |
| 164 | + |
| 165 | +Whenever you: |
| 166 | + |
| 167 | +```bash |
| 168 | +git add . |
| 169 | +git commit -m "update" |
| 170 | +git push |
| 171 | +``` |
| 172 | + |
| 173 | +👉 Vercel automatically rebuilds and redeploys. |
| 174 | +👉 Your Android app instantly shows the new version the next time it’s opened. |
| 175 | +✅ No APK rebuild or resend required! |
| 176 | + |
| 177 | +--- |
| 178 | + |
| 179 | +## 📦 **STEP 10: Build a Release APK (optional)** |
| 180 | + |
| 181 | +When you’re ready to share or upload to Play Store: |
| 182 | + |
| 183 | +In Android Studio: |
| 184 | + |
| 185 | +``` |
| 186 | +Build → Build Bundle(s)/APK(s) → Build APK(s) |
| 187 | +``` |
| 188 | + |
| 189 | +You’ll find your APK here: |
| 190 | + |
| 191 | +``` |
| 192 | +android/app/build/outputs/apk/release/app-release.apk |
| 193 | +``` |
| 194 | + |
| 195 | +You can now install this on any device. |
| 196 | + |
| 197 | +--- |
| 198 | + |
| 199 | + |
| 200 | + |
| 201 | +## ✅ FINAL WORKFLOW SUMMARY |
| 202 | + |
| 203 | +| Step | Command / Action | |
| 204 | +| ------------------------- | -------------------------------------- | |
| 205 | +| Build Angular | `ng build --configuration production` | |
| 206 | +| Push to GitHub | `git push` | |
| 207 | +| Vercel deploys | (auto) | |
| 208 | +| Update Android app config | Edit `capacitor.config.ts` once | |
| 209 | +| Sync to Android | `npx cap sync` | |
| 210 | +| Run in Studio | `npx cap open android` → ▶️ | |
| 211 | +| Future updates | Just push to GitHub — app auto-updates | |
| 212 | + |
| 213 | +--- |
0 commit comments