3.9 KiB
3.9 KiB
Android App Update Flow
Overview
The app checks for updates itself via the App settings dialog. When a newer version is available, the user can download and install it directly from within the app. No Play Store is involved.
Key Files
| File | Role |
|---|---|
app/Http/Controllers/AppVersionController.php |
Serves /app/version JSON with current versionCode, versionName, and apkUrl |
storage/app/public/apk/timebank-cc-{version}.apk |
APK served to users |
scripts/deploy-apk.sh |
Uploads APK to server and patches the version controller |
AndroidStudioProjects/Timebankcc/app/build.gradle.kts |
Android version numbers |
How the In-App Update Check Works
- User opens App settings → Check for updates
- App fetches
https://timebank.cc/app/version— returns:{ "versionCode": 4, "versionName": "1.0.2", "apkUrl": "https://timebank.cc/storage/apk/timebank-cc-1.0.2.apk" } - If
serverVersionCode > BuildConfig.VERSION_CODE, the Download and install button appears - User taps it — the APK is downloaded to the app's internal cache dir and the system installer is launched
- Android asks the user to confirm installation (
REQUEST_INSTALL_PACKAGESpermission required)
Release Process
Step 1 — Bump version in Android Studio
In app/build.gradle.kts:
versionCode = 5 // increment by 1 each release
versionName = "1.0.3" // semantic version shown to users
Step 2 — Build a signed APK
Build → Generate Signed Bundle / APK → APK → release
Output: app/release/app-release.apk
Step 3 — Copy to local storage folder
Rename and place in the local APK folder:
cp ~/AndroidStudioProjects/Timebankcc/app/release/app-release.apk \
storage/app/public/apk/timebank-cc-1.0.3.apk
The filename must follow the pattern timebank-cc-{versionName}.apk.
Step 4 — Deploy to server
bash scripts/deploy-apk.sh
The script:
- Picks the most recently modified
timebank-cc-*.apkfromstorage/app/public/apk/ - Derives
versionNamefrom the filename - Auto-increments
versionCodeif the version name has changed - SCPs the APK to
/var/www/timebank_cc/storage/app/public/apk/on the server - Patches
$versionCodeand$versionNameinAppVersionController.phpon both the server and locally
Version Number Rules
versionCode— integer, must increase with every release. The app compares this to decide whether an update is available. The deploy script increments it automatically.versionName— human-readable string shown in the App settings dialog (e.g.1.0.3). Derive the APK filename from this.
APK Storage
- Local:
storage/app/public/apk/(symlinked topublic/storage/apk/) - Remote:
/var/www/timebank_cc/storage/app/public/apk/ - Public URL:
https://timebank.cc/storage/apk/timebank-cc-{versionName}.apk
Old APK files can be kept or deleted — only the filename referenced by AppVersionController is served to users.
Permissions Required (AndroidManifest.xml)
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
This allows the app to launch the system installer for the downloaded APK.
Troubleshooting
"Download failed — please try again"
- Check that the APK filename in
AppVersionController.phpexactly matches the file instorage/app/public/apk/ - Verify the file is publicly accessible:
curl -I https://timebank.cc/storage/apk/timebank-cc-{version}.apk - APK is saved to
cacheDir(internal) — no storage permission needed
Update not offered to users
- Confirm
versionCodeon the server is higher than theversionCodebaked into the installed APK (BuildConfig.VERSION_CODE) - Check
/app/versionresponse:curl https://timebank.cc/app/version
Users not seeing the update without checking manually
- By design — the check is manual via App settings. There is no background polling.