apache / cordova-plugin-camera

Apache Cordova Plugin camera
https://cordova.apache.org/
Apache License 2.0
960 stars 1.52k forks source link

No possible way to make plugin work on Android SDK levels 21 to 33? #871

Closed andreszs closed 6 months ago

andreszs commented 6 months ago

For what I've been reading, the plugin that fixes the Android 13 incompatibility is version 7.0.0-dev, which requires cordova-android@12. I understand that this immediately drops compatibility with Android 5/6.

In order to keep Android 5/6 compatibility, cordova-android@11 must be used, making it impossible to install the fixed plugin version 7.

In short, if the developer needs to upload a version compatible from Android 5 to 13, then 2 apps must be compiled as follows:

  1. APK with android-minSdkVersion 21 and cordova-android@11 + camera plugin version 6
  2. APK with android-minSdkVersion 23 and cordova-android@12 + camera plugin version 7 (dev) non-stable

This approach, while incredibly efficient in meeting Google's obsession of rendering fully functional devices obsolete as fast as possible, is not practical to developers nor users. Is there any other solution?

In short, can someone explain why the plugin cannot be compatible with API level 21 and 33 at the same time? Sometimes, things as trivial as replacing a higher SDK constants like Build.VERSION_CODES.TIRAMISU with just "33" are enough to make apps compatible with lower SDK levels, but I'm not saying this is the case with the camera plugin version 7-dev.

Is it too complex to apply that cordova-android@12 code conditionally by means of simply checking the current SDK level? If the level is not met, then keep using the 6.0.0 functionality, if it's met, then implement all the SDK 33 code required to fix the problem.

PS. please spare me the "SDK 21 level support has been dropped by Google" mumbo-jumbo. Such nonsense is not a valid reason to make this plugin intentionally incompatible.

breautek commented 6 months ago

There's likely nothing in the camera plugin specifically (although wouldn't be tested) that requires API 24+ but the camera plugin requires cordova-android@12 since that's the version that sets the compile SDK to API 33, which is needed to reference the new API 33 permissions.

Is it too complex to apply that cordova-android@12 code conditionally by means of simply checking the current SDK level?

Doing this requires using reflection to access bits needed at compile time, and reflection introduces harder to maintain code, so yes.

cordova-android@12 platform introduces changes that requires API 24. If you have a specific need to support API 21+ devices, then you can likely fork cordova-android@11 and this plugin and make the necessary modifications to target and compile with API 33 (and remove the cordova-android@12 requirement on the camera plugin). Might be necessary to review the commit log to bring in important things for API 33 support for the fork.

I'm closing this issue because I don't foresee any action to be taken by Apache. Should you go with the fork route and have further questions, slack community members (signup) might be able to provide insight.

nacho004 commented 4 months ago

@andreszs I forked repo and changed cordova-android 12 dependency to 11. In cordova-android 11 minSdkVersion 21 is allowed and also targetSdkVersion 33.

I tested in Android 13 and lower versions and is working.

https://github.com/nacho004/cordova-plugin-camera