It's the DCIM folder!
Okay. For those who still are facing the abrupt camera crash after taking a photo, it is
likely a permission issue(owner and group messed up) on DCIM folder on the internal
SD card. So, to confirm it, on adb shell, check logcat command's output. If it says,
permission denied for the file created(JPEG file) for the photo taken, then it's indeed
the issue. So, rename the DCIM folder to something else like DCIM1. Now, close the
camera app if already open and reopen, take a photo, and see the crash won't happen.
And there is a new DCIM folder created with your photo file(JPEG) in it. Once done,
move the contents of DCIM1 to the new DCIM folder so that your gallery will show all
the old photos, etc. If you need root access to change permissions, etc of folders within
DCIM, switch to root(su command), if your device is rooted. Or else figure out some
other way to get the permissions to move them.
DCIM should have media_rw as the owner and group instead of system, etc as the
owner and/or group. Check it with ls -l output.
Here are the steps I followed to stop "Camera has stopped" and "Camera keeps
stopping" issue on Android 7.1.2 DarkROM :
======
Command on Linux PC : adb shell
Android shell :
hammerhead:/ $
hammerhead:/ $ logcat | grep Camera
E CAM_CaptureSessionImpl: java.io.FileNotFoundException: /storage/emulated/0/DCIM/Camera/IMG_date..somefilename.jpg (Permission denied)
hammerhead:/ $
======
Now, open Camer app on mobile, take a photo, open that photo from gallery
if possible. Keep an eye on logcat output. If it shows, permission denied as
above, the fix it like below.
======
hammerhead:/ $ su
hammerhead:/ #
hammerhead:/ # cd /storage/emulated/0/
hammerhead:/storage/emulated/0 #
hammerhead:/storage/emulated/0 # mv DCIM DCIM1
hammerhead:/storage/emulated/0 # exit
hammerhead:/ $
hammerhead:/ $ exit
======
Close camera app on mobile. Open camera app. Take a photo. Open the photo taken
from gallery. Camera won't crash and the photo taken should be seen. Now , move the
contents old DCIM to new DCIM.
======
hammerhead:/ $ su
hammerhead:/ # cd /storage/emulated/0/DCIM1
hammerhead:/storage/emulated/0/DCIM1 # mv ../DCIM/* .
hammerhead:/storage/emulated/0/DCIM1 # mv ../DCIM/Camera/* Camera/
======
Check that gallery now shows all the old photos, etc.. from old DCIM folder.
Cheers.
PS: I suspected it's NOT a hardware issue as it worked a day before. There was some
file system permission, SELinux, etc issue as I was experimenting with my Android
Dark ROM in recovery mode. Thereafter, the Camera app and all the third-party Camera
apps on Google Play started behaving weirdly! So, "logcat" became the savior! And I
got the idea of renaming the DCIM folder from another blog post where Screenshot was
not being saved, and solution to that was to rename "Pictures" folder to something else
and try.