Overview
Vocab Vault uses Capacitor to package the web app as a native Android application. Capacitor provides a web-native runtime that allows your React app to run as a native mobile app with access to native device APIs.Prerequisites
Before building for Android, ensure you have:- Node.js and npm installed
- Android Studio installed and configured
- Java Development Kit (JDK) 17 or higher
- Android SDK (installed via Android Studio)
- Gradle (comes with Android Studio)
Capacitor Configuration
The app’s Capacitor configuration is defined incapacitor.config.ts:
- appId: Unique identifier for the Android package (
com.dbcreations.vocabvault) - appName: Display name shown to users (Vocab Vault)
- webDir: Directory containing the built web app (
dist)
Setup Android Platform
Install Capacitor CLI
The Capacitor CLI is already included in the project dependencies. Verify installation:
Build the web app
Create a production build of the React app:This generates optimized files in the
dist/ directory.Add Android platform
If you haven’t already added the Android platform:This creates an
android/ directory with the native Android project.Building the Android App
Open in Android Studio
Open the Android project in Android Studio:Build from Android Studio
Select build variant
In Android Studio, select Build > Select Build Variant and choose:
- debug for development builds
- release for production builds
Generate APK or Bundle
- For testing: Build > Build Bundle(s) / APK(s) > Build APK(s)
- For Google Play: Build > Build Bundle(s) / APK(s) > Build Bundle(s)
Build from Command Line
Alternatively, build from the command line:- APK:
android/app/build/outputs/apk/ - Bundle:
android/app/build/outputs/bundle/
Testing on Device
Using Android Studio
- Connect an Android device via USB or start an emulator
- Click the Run button (green play icon) in Android Studio
- Select your target device
- The app will be installed and launched
Using Command Line
Updating Web Assets
Whenever you make changes to the web app:Native Plugins Used
Vocab Vault uses the following Capacitor plugins:Preferences Plugin
Share Plugin
Deployment to Google Play
Prepare store listing
Create:
- App icon (512x512 PNG)
- Feature graphic (1024x500 PNG)
- Screenshots (at least 2)
- App description and metadata
Troubleshooting
Capacitor Sync Fails
- Ensure the web app is built:
npm run build - Check that
dist/directory exists and contains built files - Verify
webDir: 'dist'incapacitor.config.ts
Android Studio Build Errors
Gradle sync failed:- Ensure JDK 17+ is installed
- Set
JAVA_HOMEenvironment variable - Configure JDK in Android Studio preferences
Plugin Not Found
If a Capacitor plugin isn’t recognized:Live Reload for Development
For faster development cycles, use live reload:App Crashes on Launch
- Check Android Studio Logcat for error messages
- Verify all plugins are installed:
npx cap sync - Ensure minimum SDK version requirements are met
- Test in a clean build:
./gradlew clean