apache / cordova-plugin-camera

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

App crashing when TargetSDK - 34 #892

Closed pjdpaulsagnik closed 3 months ago

pjdpaulsagnik commented 3 months ago

Bug Report Problem Description Expected Behavior To be able to take photos using the camera.

Actual Behavior The app crashes.

Related Information Reproduction Steps: Launch the app. Activate the camera function and tap the capture button. The app crashes. Additional Context or Information: Device: Samsung M15

Operating System: Android 14 cordova plugin list backgroundapprun 0.0.1 "backgroundAppRun" com-sarriaroman-photoviewer 1.2.4 "PhotoViewer" cordova-background-geolocation 4.15.0 "BackgroundGeolocation" cordova-plugin-android-permissions 1.1.5 "Permissions" cordova-plugin-app-version 0.1.9 "AppVersion" cordova-plugin-background-fetch 7.2.4 "CDVBackgroundFetch" cordova-plugin-background-mode 0.7.3 "BackgroundMode" cordova-plugin-camera 6.0.1-dev "Camera" cordova-plugin-console 1.1.0 "Console" cordova-plugin-device 2.0.2 "Device" cordova-plugin-dialogs 2.0.1 "Notification" cordova-plugin-file-opener2 3.0.5 "File Opener2" cordova-plugin-file-transfer 1.7.1 "File Transfer" cordova-plugin-file 6.0.2 "File" cordova-plugin-firebasex 14.0.0 "Google Firebase Plugin" cordova-plugin-inappbrowser 3.0.0 "InAppBrowser" cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard" cordova-plugin-ionic-webview 5.0.0 "cordova-plugin-ionic-webview" cordova-plugin-network-information 3.0.0 "Network Information" cordova-plugin-splashscreen 5.0.2 "Splashscreen" cordova-plugin-statusbar 2.4.2 "StatusBar" cordova-plugin-streaming-media 2.3.0 "StreamingMedia" cordova-plugin-vibration 3.1.0 "Vibration" cordova-plugin-whitelist 1.3.5 "Whitelist" cordova-plugin-x-socialsharing 6.0.4 "SocialSharing" cordova-plugin-x-toast 2.7.3 "Toast" es6-promise-plugin 4.2.2 "Promise"

Command or Code $scope.showActionSheet = function () { console.log("LOG Action Sheet !"); $ionicPopup.show({ title: 'Upload Image', subTitle: '', scope: $scope, buttons: [ { text: '

Camera

' , onTap: function(e) { $scope.openCameraTEST(); } }, ] }); };

    $scope.openCameraTEST = function () {

        var options = {
            quality: 75,
            allowEdit: false,
            sourceType: 1,
            destinationType: 0
        };
        cordova.plugins.backgroundMode.enable();
        Camera.getPicture(options).then(function (imageData) {
            console.log("imageData : ",imageData);
            cordova.plugins.backgroundMode.disable();
            $scope.data.doc_path = "data:image/jpeg;base64," + imageData;
            console.log("$scope.data.doc_path : ",$scope.data.doc_path);
        }, function (err) {
            console.log(err);
        });
    }

Environment, Platform, Device Platform: Android Device: Samsung M15

Version Information Cordova: Cordova Android 10.1.1 Operating System: Android 14

Checklist Searched for existing GitHub issues. Included all the necessary information above.

Problem :

When TargetSDK set to - API - 34, App is crashing for most of the android versions.

Please release an update for TargetSDK - 34

breautek commented 3 months ago

You're using severely out-dated platform and plugins.

API 34 support comes with cordova-android@13 and cordova-plugin-camera@7. Since version 10, there's been several breaking changes to keep up with upstream breaking changes in the Android SDK. See the following blog posts for breaking changes / migration notes.

  • cordova-android@11
  • cordova-android@12 has no significant breaking changes that won't be covered by cordova-android@13. Except for NodeJS 14 support is dropped, the new minimum NodeJS is 16.13. Recommended version is to use NodeJS LTS (Currently NodeJS 20)
  • cordova-android@13 (cordova-android@13 targets SDK 34, which requires a lot of other environment updates, including JDK 17, Gradle 8, etc)

These updates will break several of your plugins which will have updates for.

cordova-plugin-whitelist 1.3.5

This plugin is obsolete since cordova-anroid@11 and is effectively included under the core platform as allow-list. The access/allow directives in the config were not changed. The whitelist plugin can be removed.

cordova-plugin-splashscreen 5.0.2

This plugin is now also obsolete except for the browser platform since cordova-android@11. If you also maintain a browser platform, then upgrade this package to the latest version which only includes an implementation for the browser platform. Otherwise it can safely be removed.

If you're also maintaining an old version of ios platform in your plugin, the splashscreen plugin may still be needed. I'm not sure if there is a version of this plugin that has an iOS implementation without the android implementation, therefore you may need to upgrade the iOS platform as well.

cordova-plugin-file 6.0.2 "File"

There is a version 8 which includes API 34 support.

cordova-plugin-file-transfer 1.7.1 "File Transfer"

This will break because it had dependencies on the whitelist plugin which is no longer supported. Upgrade to v2 of the plugin for cordova-android@13 / API 34 support. It will also depend on cordova-plugin-file@8

cordova-plugin-camera 6.0.1-dev "Camera"

cordova-plugin-camera@7 will include API 34 support.

Additional Notes

  • API 33 introduces several breaking changes on how the android's external filesystem is accessed (generally will user documents, images, and other media is stored). It also introduces a lot more restrictions on raw filesystem APIs. Some actions that was possible before is no longer possible using the file system plugin. Many of these restrictions started since scoped storage and is documented here

  • Above I've noted several plugins that requires updates either because I know they will break on the platform upgrade or that it requires updates for API 33/34 support. I cannot comment on third-party plugins because I do not know what they do or how they will behave. An omission of a plugin comment does not mean it won't have required or recommended updates. You will have to conduct you're research on the other plugins to see if they have updates available, especially any that are necessary.

  • Don't forget to cordova plugin/platform remove to remove the plugins/platforms, followed by cordova plugin/platform add to upgrade the package. In-place upgrades aren't supported so simply adding a new version will not actually upgrade the package to the newer version.

I'm closing this issue because it doesn't describe a bug with the camera plugin.