You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Karl Kemp (JIRA)" <ji...@apache.org> on 2015/12/17 20:33:46 UTC

[jira] [Created] (CB-10219) App crash when using camera plugin with Android platform 5.0.0 on SDK23 device

Karl Kemp created CB-10219:
------------------------------

             Summary: App crash when using camera plugin with Android platform 5.0.0 on SDK23 device
                 Key: CB-10219
                 URL: https://issues.apache.org/jira/browse/CB-10219
             Project: Apache Cordova
          Issue Type: Bug
          Components: Android, Plugin Camera
    Affects Versions: 5.0.0
            Reporter: Karl Kemp


In my app I call the camera plugin like this:

    return new Promise(function (resolve, reject) {

            //PhoneGap camera API
            navigator.camera.getPicture(
                function (imageLocalFilePath) { //Success callback
   
                    resolve(imageLocalFilePath);
                },
                function (errorMessage)  { //Error callback

                    reject(new Error(errorMessage));
                }, 
                 { //Image capture options
                    quality: 50,
                    destinationType: Camera.DestinationType.FILE_URI,
                    encodingType: Camera.EncodingType.JPEG,
                    targetWidth: targetWidth,
                    targetHeight: targetHeight,
                    mediaType: Camera.MediaType.PICTURE,
                    correctOrientation: true,
                    saveToPhotoAlbum: useCameraRoll
                });
        });

When this code runs on my Asus Nexus 7 running Android 6.0 (API23) I get the permission prompt as expected when I click the take photo button within the app for the first time.  I click the "Accept" button but the app immediately crashes with the following error, which seems to say that permission was denied:  

12-17 14:27:52.083 21930-21930/com.lifecyclemobile.fivespark E/AndroidRuntime: FATAL EXCEPTION: main
                                                                               Process: com.lifecyclemobile.fivespark, PID: 21930
                                                                               java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=0, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {com.lifecyclemobile.fivespark/com.lifecyclemobile.fivespark.MainActivity}: java.lang.SecurityException: Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.google.android.GoogleCamera/com.android.camera.CaptureActivity clip={text/uri-list U:file:///storage/emulated/0/Android/data/com.lifecyclemobile.fivespark/cache/.Pic.jpg} (has extras) } from ProcessRecord{513cbe8 21930:com.lifecyclemobile.fivespark/u0a235} (pid=21930, uid=10235) with revoked permission android.permission.CAMERA
                                                                                   at android.app.ActivityThread.deliverResults(ActivityThread.java:3699)
                                                                                   at android.app.ActivityThread.handleSendResult(ActivityThread.java:3742)
                                                                                   at android.app.ActivityThread.-wrap16(ActivityThread.java)
                                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393)
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                   at android.os.Looper.loop(Looper.java:148)
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:5417)
                                                                                   at java.lang.reflect.Method.invoke(Native Method)
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
                                                                                Caused by: java.lang.SecurityException: Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.google.android.GoogleCamera/com.android.camera.CaptureActivity clip={text/uri-list U:file:///storage/emulated/0/Android/data/com.lifecyclemobile.fivespark/cache/.Pic.jpg} (has extras) } from ProcessRecord{513cbe8 21930:com.lifecyclemobile.fivespark/u0a235} (pid=21930, uid=10235) with revoked permission android.permission.CAMERA
                                                                                   at android.os.Parcel.readException(Parcel.java:1599)
                                                                                   at android.os.Parcel.readException(Parcel.java:1552)
                                                                                   at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2658)
                                                                                   at android.app.Instrumentation.execStartActivity(Instrumentation.java:1507)
                                                                                   at android.app.Activity.startActivityForResult(Activity.java:3917)
                                                                                   at org.apache.cordova.CordovaActivity.startActivityForResult(CordovaActivity.java:332)
                                                                                   at android.app.Activity.startActivityForResult(Activity.java:3877)
                                                                                   at org.apache.cordova.CordovaInterfaceImpl.startActivityForResult(CordovaInterfaceImpl.java:63)
                                                                                   at org.apache.cordova.camera.CameraLauncher.takePicture(CameraLauncher.java:268)
                                                                                   at org.apache.cordova.camera.CameraLauncher.onRequestPermissionResult(CameraLauncher.java:1205)
                                                                                   at org.apache.cordova.CordovaInterfaceImpl.onRequestPermissionResult(CordovaInterfaceImpl.java:182)
                                                                                   at org.apache.cordova.CordovaActivity.onRequestPermissionsResult(CordovaActivity.java:498)
                                                                                   at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:6553)
                                                                                   at android.app.Activity.dispatchActivityResult(Activity.java:6432)
                                                                                   at android.app.ActivityThread.deliverResults(ActivityThread.java:3695)
                                                                                   at android.app.ActivityThread.handleSendResult(ActivityThread.java:3742) 
                                                                                   at android.app.ActivityThread.-wrap16(ActivityThread.java) 
                                                                                   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1393) 
                                                                                   at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                   at android.os.Looper.loop(Looper.java:148) 
                                                                                   at android.app.ActivityThread.main(ActivityThread.java:5417) 
                                                                                   at java.lang.reflect.Method.invoke(Native Method) 
                                                                                   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
                                                                                   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

My app is using Android platform 5.0.0 and Camera plugin 2.0.0 

If I go into settings and manually enable the camera permission for my app, it works as expected.  It also works as expected on older versions of Android.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org