Prerequisites
Before setting up the Android app, ensure you have the following installed:Install Android Studio
Download and install Android Studio with the following components:
- Android SDK
- Android SDK Platform
- Android Virtual Device (AVD)
Configure Environment Variables
Add the following to your shell profile (
~/.bashrc, ~/.zshrc, etc.):Project Configuration
MediGuide uses Capacitor 8.1.0 to bridge the web application with native Android functionality.Build Configuration
The Android project uses the following configuration:android/variables.gradle
MediGuide requires a minimum Android SDK version of 24 (Android 7.0 Nougat).
Installing Dependencies
Install Node Dependencies
First, install all Node.js dependencies:This will install Capacitor and all required packages including:
@capacitor/android(^8.1.0)@capacitor/cli(^8.1.0)@capacitor/core(^8.1.0)
Build Web Assets
Build the web application that will be bundled into the Android app:This creates the production build in the
dist directory.Building the Android App
Using Android Studio
Using Command Line
You can also build the app using Gradle from the command line:Running the App
On an Emulator
Create an AVD
In Android Studio:
- Go to Tools > Device Manager
- Click Create Device
- Select a device definition (e.g., Pixel 5)
- Download and select a system image (Android 7.0 or higher)
- Finish setup
On a Physical Device
Enable Developer Options
On your Android device:
- Go to Settings > About Phone
- Tap Build Number 7 times
- Navigate to Settings > Developer Options
- Enable USB Debugging
Connect Device
Connect your device via USB and verify it’s recognized:You should see your device listed.
Project Structure
The Android project structure follows the standard Capacitor layout:MainActivity
The main entry point for the Android app extends Capacitor’sBridgeActivity:
android/app/src/main/java/com/mediguide/app/MainActivity.java
Capacitor handles all the bridging between your web code and native Android functionality through
BridgeActivity.Common Issues
Gradle Build Failures
If you encounter Gradle build errors:-
Clean the project:
-
Invalidate caches in Android Studio:
- File > Invalidate Caches > Invalidate and Restart