Prerequisites
Before building the Android app, ensure you have the following installed:- Node.js (v16 or higher)
- Android Studio (latest stable version)
- Java Development Kit (JDK) 17 or higher
- Android SDK with the following components:
- Android SDK Platform 35 (API Level 35)
- Android SDK Build-Tools
- Android SDK Command-line Tools
Environment Setup
Install Android Studio
Download and install Android Studio from the official website.
Configure Android SDK
Open Android Studio and navigate to Settings > Appearance & Behavior > System Settings > Android SDK.Install the following:
- Android SDK Platform 35 (compileSdk version)
- Android SDK Build-Tools 35.0.0 or higher
Project Configuration
The Android app is configured with the following specifications:| Property | Value |
|---|---|
| Application ID | com.ciclovital.app |
| Namespace | com.ciclovital.app |
| Min SDK Version | 23 (Android 6.0) |
| Target SDK Version | 35 (Android 15) |
| Compile SDK Version | 35 |
| Version Code | 1 |
| Version Name | 1.0 |
Gradle Configuration
The project uses the following key dependencies:android/variables.gradle
Building the Android App
Build the Web Assets
Build the React application that will be bundled into the Android app:This creates optimized production files in the
dist directory, which Capacitor will use as the web runtime.Sync Capacitor
Copy the web assets to the Android platform and update native dependencies:This command:
- Copies the built web app from
disttoandroid/app/src/main/assets/public - Updates Capacitor plugins
- Syncs configuration from
capacitor.config.json
Open in Android Studio
Open the Android project in Android Studio:Alternatively, open the
android directory directly in Android Studio.Running on a Device
Using an Emulator
Create an AVD
In Android Studio, open Device Manager and create a new Android Virtual Device (AVD).Recommended configuration:
- Device: Pixel 6 or similar
- System Image: Android 15 (API 35) or Android 13 (API 33)
- RAM: 2048 MB or higher
Using a Physical Device
Enable Developer Options
On your Android device:
- Go to Settings > About Phone
- Tap Build Number 7 times to enable Developer Options
- Go back to Settings > System > Developer Options
- Enable USB Debugging
Connect and Verify
Connect your device via USB and verify it’s recognized:You should see your device listed. Accept the USB debugging prompt on your device.
Development Workflow
For faster development iterations with live reload:Start the Dev Server
Run the Vite development server:The server will start on
http://localhost:5173 (or another port if 5173 is busy).Update Capacitor Config
Temporarily modify Replace
capacitor.config.json to point to your dev server:YOUR_LOCAL_IP with your machine’s local IP address (e.g., 192.168.1.100).Building for Release
Generate a Signing Key
Create a keystore for signing your release APK:Store the keystore file and password securely.
Configure Signing
Create Add signing configuration to
android/app/signing.properties:android/app/build.gradle:Troubleshooting
Gradle Build Failures
If Gradle fails to build:SDK Version Mismatches
Ensure you have Android SDK 35 installed. Check in Android Studio: Settings > Appearance & Behavior > System Settings > Android SDKADB Device Not Found
Ifadb devices doesn’t show your device:
Port Already in Use
If the dev server port is busy:server.url in capacitor.config.json accordingly.
Next Steps
Capacitor Configuration
Learn about Capacitor plugins and configuration
