Files
crowd-funder-for-time-pwa/doc/android-api-23-upgrade-impact-analysis.md
Jose Olarte III 84983ee10b refactor(shared-image): replace temp file approach with native Capacitor plugins
Replace the buggy temp file polling mechanism with direct native-to-JS
communication via custom Capacitor plugins for iOS and Android. This
eliminates race conditions, file management complexity, and polling overhead.

BREAKING CHANGE: Removes backward compatibility with temp file approach.
Android minSdkVersion upgraded from 22 to 23.

Changes:
- iOS: Created SharedImagePlugin (CAPBridgedPlugin) and SharedImageUtility
  - Uses App Group UserDefaults for data sharing between extension and app
  - Implements getSharedImage() and hasSharedImage() methods
  - Removes temp file writing/reading logic from AppDelegate
- Android: Created SharedImagePlugin with @CapacitorPlugin annotation
  - Uses SharedPreferences for data storage instead of temp files
  - Implements same interface as iOS plugin
  - Removes temp file handling from MainActivity
- TypeScript: Added plugin definitions and registration
  - Created SharedImagePlugin interface and web fallback
  - Updated main.capacitor.ts to use plugin instead of Filesystem API
  - Removed pollForFileExistence() and related file I/O code
- Android: Upgraded minSdkVersion from 22 to 23
  - Required for SharedPreferences improvements and better API support

Benefits:
- Eliminates race conditions from file polling
- Removes file cleanup complexity
- Direct native-to-JS communication (no file I/O)
- Better performance (no polling overhead)
- More reliable data transfer between share extension and app
- Cleaner architecture with proper plugin abstraction
2025-12-04 18:03:47 +08:00

8.2 KiB

Android API 23 Upgrade Impact Analysis

Date: 2025-12-03
Current minSdkVersion: 22 (Android 5.1 Lollipop)
Proposed minSdkVersion: 23 (Android 6.0 Marshmallow)
Impact Assessment: Low to Moderate

Executive Summary

Upgrading from API 22 to API 23 will have minimal code impact but may affect device compatibility. The main change is that API 23 introduced runtime permissions, but since the app uses Capacitor plugins which handle permissions, the impact is minimal.

Code Impact Analysis

No Breaking Changes in Existing Code

1. API Level Checks in Code

All existing API level checks are for much higher APIs than 23, so they won't be affected:

MainActivity.java:

  • Build.VERSION_CODES.R (API 30+) - Edge-to-edge display
  • Build.VERSION_CODES.TIRAMISU (API 33+) - Intent extras handling
  • Legacy path (API 21-29) - Will still work, but API 22 devices won't be supported

SafeAreaPlugin.java:

  • Build.VERSION_CODES.R (API 30+) - Safe area insets

Conclusion: No code changes needed for API level checks.

2. Permissions Handling

Current Permissions in AndroidManifest.xml:

  • INTERNET - Normal permission (no runtime needed)
  • READ_EXTERNAL_STORAGE - Dangerous permission (runtime required on API 23+)
  • WRITE_EXTERNAL_STORAGE - Dangerous permission (runtime required on API 23+)
  • CAMERA - Dangerous permission (runtime required on API 23+)

Current Implementation:

  • App uses Capacitor plugins for camera and file access
  • Capacitor plugins already handle runtime permissions automatically
  • No manual permission request code found in the codebase
  • QR Scanner uses Capacitor's BarcodeScanner plugin which handles permissions

Conclusion: No code changes needed - Capacitor handles runtime permissions automatically.

3. Dependencies Compatibility

AndroidX Libraries:

  • androidx.appcompat:appcompat:1.6.1 - Supports API 23+
  • androidx.core:core:1.12.0 - Supports API 23+
  • androidx.fragment:fragment:1.6.2 - Supports API 23+
  • androidx.coordinatorlayout:coordinatorlayout:1.2.0 - Supports API 23+
  • androidx.core:core-splashscreen:1.0.1 - Supports API 23+

Capacitor Plugins:

  • @capacitor/core:6.2.0 - Requires API 23+ (official requirement)
  • @capacitor/camera:6.0.0 - Handles runtime permissions
  • @capacitor/filesystem:6.0.0 - Handles runtime permissions
  • @capacitor-community/sqlite:6.0.2 - Supports API 23+
  • @capacitor-mlkit/barcode-scanning:6.0.0 - Supports API 23+

Third-Party Libraries:

  • No Firebase or other libraries with API 22-specific requirements found
  • All dependencies appear compatible with API 23+

Conclusion: All dependencies are compatible with API 23.

4. Build Configuration

Current Configuration:

  • compileSdkVersion = 36 (Android 14)
  • targetSdkVersion = 36 (Android 14)
  • minSdkVersion = 22 (Android 5.1) ← Only this needs to change

Required Change:

// android/variables.gradle
ext {
    minSdkVersion = 23  // Change from 22 to 23
    // ... rest stays the same
}

Conclusion: Only one line needs to be changed.

Device Compatibility Impact

Device Coverage Loss

API 22 (Android 5.1 Lollipop):

  • Released: March 2015
  • Market share: ~0.1% of active devices (as of 2024)
  • Devices affected: Very old devices from 2015-2016

API 23 (Android 6.0 Marshmallow):

  • Released: October 2015
  • Market share: ~0.3% of active devices (as of 2024)
  • Still very low, but slightly higher than API 22

Impact: Losing support for ~0.1% of devices (essentially negligible)

User Base Impact

Recommendation: Check your analytics to see actual usage:

  • If you have analytics, check percentage of users on API 22
  • If < 0.5%, upgrade is safe
  • If > 1%, consider the business impact

Runtime Permissions (API 23 Feature)

What Changed in API 23

Before API 23 (API 22 and below):

  • Permissions granted at install time
  • User sees all permissions during installation
  • No runtime permission dialogs

API 23+ (Runtime Permissions):

  • Dangerous permissions must be requested at runtime
  • User sees permission dialogs when app needs them
  • Better user experience and privacy

Current App Status

Already Compatible:

  • App uses Capacitor plugins which automatically handle runtime permissions
  • Camera plugin requests permissions when needed
  • Filesystem plugin requests permissions when needed
  • No manual permission code needed

Conclusion: App is already designed for runtime permissions via Capacitor.

Potential Issues to Watch

1. APK Size

  • Some developers report APK size increases after raising minSdkVersion
  • Action: Monitor APK size after upgrade
  • Expected Impact: Minimal (API 22 → 23 is a small jump)

2. Testing Requirements

  • Need to test on API 23+ devices
  • Action: Test on Android 6.0+ devices/emulators
  • Current: App likely already tested on API 23+ devices

3. Legacy Code Path

  • MainActivity has legacy code for API 21-29
  • Impact: This code will still work, but API 22 devices won't be supported
  • Action: No code changes needed, but legacy path becomes API 23-29

4. Capacitor Compatibility

  • Capacitor 6.2.0 officially requires API 23+
  • Current Situation: App runs on API 22 (may be working due to leniency)
  • After Upgrade: Officially compliant with Capacitor requirements
  • Benefit: Better compatibility guarantees

Files That Need Changes

1. Build Configuration

File: android/variables.gradle

ext {
    minSdkVersion = 23  // Change from 22
    // ... rest unchanged
}

2. Documentation

Files to Update:

  • doc/shared-image-plugin-implementation-plan.md - Update version notes
  • Any README files mentioning API 22
  • Build documentation

3. No Code Changes Required

  • No Java/Kotlin code changes needed
  • No AndroidManifest.xml changes needed
  • No permission handling code changes needed

Testing Checklist

After upgrading to API 23, test:

  • App builds successfully
  • App installs on API 23 device/emulator
  • Camera functionality works (permissions requested)
  • File access works (permissions requested)
  • Share functionality works
  • QR code scanning works
  • Deep linking works
  • All Capacitor plugins work correctly
  • No crashes or permission-related errors
  • APK size is acceptable

Rollback Plan

If issues arise:

  1. Revert android/variables.gradle to minSdkVersion = 22
  2. Rebuild and test
  3. Document issues encountered
  4. Address issues before retrying upgrade

Recommendation

Proceed with Upgrade

Reasons:

  1. Minimal Code Impact: Only one line needs to change
  2. Already Compatible: App uses Capacitor which handles runtime permissions
  3. Device Impact: Negligible (~0.1% of devices)
  4. Capacitor Compliance: Officially meets Capacitor 6 requirements
  5. Future-Proofing: Better alignment with modern Android development

Timeline:

  • Low Risk: Can be done anytime
  • Recommended: Before implementing SharedImagePlugin (cleaner baseline)
  • Testing: 1-2 hours of testing on API 23+ devices

Migration Steps

  1. Update Build Configuration:

    # Edit android/variables.gradle
    minSdkVersion = 23
    
  2. Sync Gradle:

    cd android
    ./gradlew clean
    
  3. Build and Test:

    npm run build:android:test
    # Test on API 23+ device/emulator
    
  4. Verify Permissions:

    • Test camera access
    • Test file access
    • Verify permission dialogs appear
  5. Update Documentation:

    • Update any docs mentioning API 22
    • Update implementation plan

Summary

Aspect Impact Status
Code Changes None required Safe
Dependencies All compatible Safe
Permissions Already handled Safe
Device Coverage ~0.1% loss ⚠️ Minimal
Build Config 1 line change Simple
Testing Standard testing Required
Risk Level Low Low Risk

Final Recommendation: Proceed with upgrade. The benefits (Capacitor compliance, future-proofing) outweigh the minimal risks (negligible device loss, no code changes needed).