Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImagePicker crash while capturing Camera Image and Camera Permission is Defined in Manifest #34

Closed
Dhaval2404 opened this issue Sep 30, 2019 · 2 comments
Labels
bug Something isn't working
Milestone

Comments

@Dhaval2404
Copy link
Owner

Today, I discover a very strange crash issue. When Camera Permission is declared in Manifest and android.media.action.IMAGE_CAPTURE intent is called then the app must request CAMERA runtime permission. Otherwise, app will be crashed.

And if we remove permission from manifest then an error will no longer be reproduced.

Found below StackOverflow link which has this kind of similar issue:
https://stackoverflow.com/questions/43042725/revoked-permission-android-permission-camera/43070198

java.lang.RuntimeException: Failure delivering result ResultInfo{who=@android:requestPermissions:, request=4282, result=-1, data=Intent { act=android.content.pm.action.REQUEST_PERMISSIONS (has extras) }} to activity {com.github.dhaval2404.imagepicker.sample/com.github.dhaval2404.imagepicker.ImagePickerActivity}: java.lang.SecurityException: Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.android.camera2/com.android.camera.CaptureActivity clip={text/uri-list U:content://com.github.dhaval2404.imagepicker.sample.provider/external_files/DCIM/Camera/IMG_20190930_230312575.jpg} (has extras) } from ProcessRecord{bfa62b 30120:com.github.dhaval2404.imagepicker.sample/u0a134} (pid=30120, uid=10134) with revoked permission android.permission.CAMERA
        at android.app.ActivityThread.deliverResults(ActivityThread.java:4845)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:4886)
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016)
        at android.os.Handler.dispatchMessage(Handler.java:107)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
     Caused by: java.lang.SecurityException: Permission Denial: starting Intent { act=android.media.action.IMAGE_CAPTURE flg=0x3 cmp=com.android.camera2/com.android.camera.CaptureActivity clip={text/uri-list U:content://com.github.dhaval2404.imagepicker.sample.provider/external_files/DCIM/Camera/IMG_20190930_230312575.jpg} (has extras) } from ProcessRecord{bfa62b 30120:com.github.dhaval2404.imagepicker.sample/u0a134} (pid=30120, uid=10134) with revoked permission android.permission.CAMERA
        at android.os.Parcel.createException(Parcel.java:2071)
        at android.os.Parcel.readException(Parcel.java:2039)
        at android.os.Parcel.readException(Parcel.java:1987)
        at android.app.IActivityTaskManager$Stub$Proxy.startActivity(IActivityTaskManager.java:3851)
        at android.app.Instrumentation.execStartActivity(Instrumentation.java:1705)
        at android.app.Activity.startActivityForResult(Activity.java:5192)
        at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:676)
        at android.app.Activity.startActivityForResult(Activity.java:5150)
        at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:663)
        at com.github.dhaval2404.imagepicker.provider.CameraProvider.startCameraIntent(CameraProvider.kt:82)
        at com.github.dhaval2404.imagepicker.provider.CameraProvider.onRequestPermissionsResult(CameraProvider.kt:96)
        at com.github.dhaval2404.imagepicker.ImagePickerActivity.onRequestPermissionsResult(ImagePickerActivity.kt:87)
        at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:8264)
        at android.app.Activity.dispatchActivityResult(Activity.java:8114)
        at android.app.ActivityThread.deliverResults(ActivityThread.java:4838)
        at android.app.ActivityThread.handleSendResult(ActivityThread.java:4886) 
        at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:51) 
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2016) 
        at android.os.Handler.dispatchMessage(Handler.java:107) 
        at android.os.Looper.loop(Looper.java:214) 
        at android.app.ActivityThread.main(ActivityThread.java:7356) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) 
     Caused by: android.os.RemoteException: Remote stack trace:
        at com.android.server.wm.ActivityStackSupervisor.checkStartAnyActivityPermission(ActivityStackSupervisor.java:1043)
        at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:760)
        at com.android.server.wm.ActivityStarter.startActivity(ActivityStarter.java:583)
        at com.android.server.wm.ActivityStarter.startActivityMayWait(ActivityStarter.java:1288)
        at com.android.server.wm.ActivityStarter.execute(ActivityStarter.java:514)
@Dhaval2404 Dhaval2404 added this to the v1.5 milestone Sep 30, 2019
@Dhaval2404
Copy link
Owner Author

Dhaval2404 commented Sep 30, 2019

If anyone facing this issue, Kindly remove Camera Permission from Manifest for now.

<uses-permission android:name="android.permission.CAMERA" />

Dhaval2404 added a commit that referenced this issue Sep 30, 2019
…ssion is Defined in Manifest

Fixed ImagePicker crash while capturing Camera Image and Camera Permission is Defined in Manifest

#34
@Dhaval2404 Dhaval2404 added the bug Something isn't working label Oct 1, 2019
Dhaval2404 added a commit that referenced this issue Oct 12, 2019
Fixed ImagePicker crash issue while capturing Camera Image and Camera Permission is Defined in Manifest

#34
Dhaval2404 added a commit that referenced this issue Oct 13, 2019
Release v1.5 with below fixes

#28 #34 #36
@Dhaval2404 Dhaval2404 mentioned this issue Oct 13, 2019
@Dhaval2404
Copy link
Owner Author

Issue resolved as of v1.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant