Files
daily-notification-plugin/test-apps/BUILD_PROCESS.md

7.2 KiB

Test Apps Build Process Review

Summary

Both test apps are configured to automatically build the plugin as part of their build process. The plugin is included as a Gradle project dependency, so Gradle handles building it automatically.


Test App 1: android-test-app (Standalone Android)

Location: test-apps/android-test-app/

Configuration

Plugin Reference (settings.gradle):

// Reference plugin from root project
def pluginPath = new File(settingsDir.parentFile.parentFile, 'android')
include ':daily-notification-plugin'
project(':daily-notification-plugin').projectDir = pluginPath

Plugin Dependency (app/build.gradle):

dependencies {
    implementation project(':capacitor-android')
    implementation project(':daily-notification-plugin')  // ✅ Plugin included
    // Plugin dependencies also included
}

Capacitor Setup:

  • References Capacitor from daily-notification-test/node_modules/ (shared dependency)
  • Includes :capacitor-android project module

Build Process

  1. Gradle resolves plugin project - Finds plugin at ../../android
  2. Gradle builds plugin module - Compiles plugin Java code to AAR (internally)
  3. Gradle builds app module - Compiles app code
  4. Gradle links plugin - Includes plugin classes in app APK
  5. Final output: app/build/outputs/apk/debug/app-debug.apk

Build Commands

Note that these require Java > 22.12

This set is for the most basic Android app:

cd android-test-app

# Build debug APK (builds plugin automatically)
./gradlew assembleDebug

# Get the full list of available AVDs
avdmanager list avd

# Run one
emulator -avd AVD_NAME

# Check that one is running
adb devices

# Now install on the emulator
adb install -r ./app/build/outputs/apk/debug/app-debug.apk

# Now start the app
adb shell am start -n com.timesafari.dailynotification/.MainActivity

# Build release APK
./gradlew assembleRelease

This set is for the Vue app (closer to Time Safari):

  • cd daily-notification-test

  • install on Vue app, build

Prerequisites

  • Gradle wrapper present (gradlew, gradlew.bat, gradle/wrapper/)
  • Capacitor must be installed in daily-notification-test/node_modules/ (shared)
  • Plugin must exist at root android/ directory

Test App 2: daily-notification-test (Vue 3 + Capacitor)

Location: test-apps/daily-notification-test/

Configuration

Plugin Installation (package.json):

{
  "dependencies": {
    "@timesafari/daily-notification-plugin": "file:../../"
  }
}

Capacitor Auto-Configuration:

  • npx cap sync android automatically:
    1. Installs plugin from file:../../node_modules/@timesafari/daily-notification-plugin/
    2. Generates capacitor.settings.gradle with plugin reference
    3. Generates capacitor.build.gradle with plugin dependency
    4. Generates capacitor.plugins.json with plugin registration

Plugin Reference (capacitor.settings.gradle - auto-generated):

include ':timesafari-daily-notification-plugin'
project(':timesafari-daily-notification-plugin').projectDir = 
    new File('../node_modules/@timesafari/daily-notification-plugin/android')

Plugin Dependency (capacitor.build.gradle - auto-generated):

dependencies {
    implementation project(':timesafari-daily-notification-plugin')
}

Build Process

  1. npm install - Installs plugin from file:../../ to node_modules/
  2. npm run build - Builds Vue 3 web app → dist/
  3. npx cap sync android - Capacitor:
    • Copies web assets to android/app/src/main/assets/
    • Configures plugin in Gradle files
    • Registers plugin in capacitor.plugins.json
  4. Fix script runs - Verifies plugin path is correct (post-sync hook)
  5. Gradle builds - Plugin is built as part of app build
  6. Final output: android/app/build/outputs/apk/debug/app-debug.apk

Build Commands

cd test-apps/daily-notification-test

# Initial setup (one-time)
npm install                    # Installs plugin from file:../../
npx cap sync android          # Configures Android build

# Development workflow
npm run build                 # Builds Vue 3 web app
npx cap sync android          # Syncs web assets + plugin config
cd android
./gradlew assembleDebug       # Builds Android app (includes plugin)

# Or use Capacitor CLI (does everything)
npx cap run android           # Builds web + syncs + builds Android + runs

Post-Install Hook

The postinstall script (scripts/fix-capacitor-plugins.js) automatically:

  • Verifies plugin is registered in capacitor.plugins.json
  • Verifies plugin path in capacitor.settings.gradle points to android/ (standard structure)
  • Fixes path if it incorrectly points to old android/plugin/ structure

Key Points

Both Apps Build Plugin Automatically

  • No manual plugin build needed - Gradle handles it
  • Plugin is a project dependency - Built before the app
  • Standard Gradle behavior - Works like any Android library module

Plugin Structure is Standard

  • Plugin location: android/src/main/java/... (standard Capacitor structure)
  • No path fixes needed - Capacitor auto-generates correct paths
  • Works with npx cap sync - No manual configuration required

Build Dependencies

android-test-app:

  • Requires Capacitor from daily-notification-test/node_modules/ (shared)
  • References plugin directly from root android/ directory

daily-notification-test:

  • Requires npm install to install plugin
  • Requires npx cap sync android to configure build
  • Plugin installed to node_modules/ like any npm package

Verification

Check Plugin is Included

# For android-test-app
cd test-apps/android-test-app
./gradlew :app:dependencies | grep daily-notification

# For daily-notification-test
cd test-apps/daily-notification-test/android
./gradlew :app:dependencies | grep timesafari

Check Plugin Registration

# Vue app only
cat test-apps/daily-notification-test/android/app/src/main/assets/capacitor.plugins.json

Should contain:

[
  {
    "name": "DailyNotification",
    "classpath": "com.timesafari.dailynotification.DailyNotificationPlugin"
  }
]

Troubleshooting

android-test-app: "Capacitor not found"

Solution: Run npm install in test-apps/daily-notification-test/ first to install Capacitor dependencies.

android-test-app: "Plugin not found"

Solution: Verify android/build.gradle exists at the root project level.

daily-notification-test: Plugin path wrong

Solution: Run node scripts/fix-capacitor-plugins.js after npx cap sync android. The script now verifies/fixes the path to use standard android/ structure.

Both: Build succeeds but plugin doesn't work

Solution:

  • Check capacitor.plugins.json has plugin registered
  • Verify plugin classes are in the APK: unzip -l app-debug.apk | grep DailyNotification

Summary

Both test apps handle plugin building automatically
Plugin uses standard Capacitor structure (android/src/main/java/)
No manual plugin builds required - Gradle handles dependencies
Build processes are configured correctly - Ready to use

The test apps are properly configured to build and test the plugin!