I am working at a app which is started from a browser - I am trying with FireFox - I get the file Uri from the Intent but I can not open the file in this path :
java.io.FileNotFoundException: /file:/storage/emulated/0/Download/baningmyheadreallyhard.txt: open failed: ENOENT (No such file or directory)
Any idea about why ?
Related
I'm migrating from HTTP to HTTP v1 for notification in android studio. have added Service-account.jason file to assets folder. But i'm not able to access the file while trying to send
notification.
getting below error:
java.io.FileNotFoundException: service-account.json: open failed: ENOENT (No such file or directory)
I am trying to copy the file from /storage/emulated/0/test.txt to /cache/SH_DIR/ via android user application ,
getting error like below
java.io.FileNotFoundException: /cache/test/test.txt: open failed: EACCES (Permission denied)
When I have created as system application like , Included Application code as past of AOSP then able to copy the file to /cache/SH_DIR/ location.
May I need to add anything in the SEpolicy to copy file to /cacahe/SH_DIR/ from user application.
Can you please help me , Thanks in advance
I have an app which records videos, it has about 80K current installations (more than 100K downloads), Crashlytics statistics seems to be good - Crash-free users 99.66% and rating on Google Play is also OK - 4.5
But still for some of my users can happen the next error (it may happened for each user once or a couple of times by now, so not often, but still happens from time to time):
java.io.FileNotFoundException:
/storage/7886-1D16/Android/media/MY_APP_PACKAGE_NAME_HERE/2021-03-18
21h 18m 06s.mp4: open failed: EROFS ... blah blah blah ... android.media.MediaRecorder.prepare(MediaRecorder.java:1028)
Here's the code (similar to real one in my project), as you can see before mediaRecorder.prepare() and video recording I check if output directory is good, if File.canWrite() returns true then it means that files exists, app has needed permission to write at this path and storage is mounted https://developer.android.com/reference/java/io/File#canWrite()
// canWrite() - means that file exists and app is allowed to write
if (outputFolderFile.canWrite()) {
// directory is OK, Android says that there is nothing wrong...
val videoFile = File(outputFolderFile, videoFileName)
... // MediaRecorder settings
mediaRecorder.setOutputFile(videoFile.absolutePath)
... // other MediaRecorder settings
try {
mediaRecorder.prepare() // FileNotFoundException here from time to time
} catch (e: Exception) {
e.printStackTrace()
openReportErrorDialog(e)
}
}
Additionally I was trying to add && Environment.getExternalStorageState(outputFolderFile).equals(Environment.MEDIA_MOUNTED)) or || (outputFolderFile.mkdirs() && outputFolderFile.canWrite()) to that condition (outputFolderFile.canWrite()) but it doesn't matter, error still happens
I also was trying to add createNewFile(videoFile ) line before mediaRecorder.prepare() but doesn't help and in this case the error is java.io.IOException: No such file or directory, java.io.IOException: No such file or directory at java.io.UnixFileSystem.createFileExclusively0(Native Method)
So Android says that directory exists, everything is ok and app can write files there but...
Here I almost added all reports from my users about this error:
HUAWEI CAG-L22
java.io.FileNotFoundException: /storage/7886-1D16/Android/media/MY_APP_PACKAGE_NAME_HERE/2021-03-18 21h 18m 06s.mp4: open failed: EROFS (Read-only file system)
HUAWEI FIG-LX1
java.io.FileNotFoundException: /storage/5309-1D08/Android/media/MY_APP_PACKAGE_NAME_HERE/2021-04-10/2021-04-10 10h 17m 18s.mp4: open failed: EROFS (Read-only file system)
LGE LG-K350
java.io.FileNotFoundException: /storage/4CA1-71F9/Android/media/MY_APP_PACKAGE_NAME_HERE/2021-04-02/2021-04-02 14h 53m 31s.mp4: open failed: ENOENT (No such file or directory)
LGE LM-K300
java.io.FileNotFoundException: /storage/C5F6-15E4/Android/media/MY_APP_PACKAGE_NAME_HERE/2021-03-06/2021-03-06 02h 26m 40s PM.mp4: open failed: ENOENT (No such file or directory)
LGE LM-X420
java.io.FileNotFoundException: /storage/B15A-170A/Android/media/MY_APP_PACKAGE_NAME_HERE/2021-02-12/2021-02-12 13h 31m 42s.mp4: open failed: ENOENT (No such file or directory)
OPPO CPH1931
java.io.FileNotFoundException: /storage/02EB-1B18/Android/media/MY_APP_PACKAGE_NAME_HERE/2021-03-13/2021-03-13 12h 15m 30s.mp4: open failed: EROFS (Read-only file system)
Prestigio PMT3257_3G
java.io.FileNotFoundException: /storage/emulated/0/Android/media/MY_APP_PACKAGE_NAME_HERE/2021-04-10/2021-04-10 10h 32m 21s.mp4: open failed: ENOENT (No such file or directory),
samsung SM-G900F
java.io.FileNotFoundException: /storage/161A-0B3C/Android/media/MY_APP_PACKAGE_NAME_HERE/2021-03-02/2021-03-02 08h 06m 33s.mp4: open failed: ENOENT (No such file or directory)
samsung SM-N960W
java.io.FileNotFoundException: /storage/2A2C-40A4/Android/media/MY_APP_PACKAGE_NAME_HERE/2021-04-14/2021-04-14 02h 35m 45s AM.mp4: open failed: ENOENT (No such file or directory)
Xiaomi M2004J19C
java.io.FileNotFoundException: /storage/emulated/0/Android/media/MY_APP_PACKAGE_NAME_HERE/2021-03-11 11h 09m 18s AM.mp4: open failed: ENOENT (No such file or directory)
Xiaomi M2007J20CG
java.io.FileNotFoundException: /storage/82AD-49E3/Android/media/MY_APP_PACKAGE_NAME_HERE/2021-04-06/2021-04-06 06h 51m 14s.mp4: open failed: ENOENT (No such file or directory)
Xiaomi M2007J3SG
java.io.FileNotFoundException: /storage/emulated/0/Movies/MY_APP_NAME_HERE/2021-03-31/2021-03-31 15h 39m 27s.mp4: open failed: EPERM (Operation not permitted)
Xiaomi M2007J3SY
java.io.FileNotFoundException: /storage/emulated/0/Movies/MY_APP_NAME_HERE/2021-04-10/2021-04-10 01h 30m 42s PM.mp4: open failed: EPERM (Operation not permitted)
Xiaomi M2102J20SG
java.io.FileNotFoundException: /storage/emulated/0/Movies/MY_APP_NAME_HERE/2021-04-17/2021-04-17 16h 16m 59s.mp4: open failed: EPERM (Operation not permitted)
Xiaomi POCO F2 Pro
java.io.FileNotFoundException: /storage/emulated/0/Movies/MY_APP_NAME_HERE/2021-02-05/2021-02-05 19h 20m 36s.mp4: open failed: EPERM (Operation not permitted)
Xiaomi Redmi 5A
java.io.FileNotFoundException: /storage/577D-D95B/Android/media/MY_APP_PACKAGE_NAME_HERE/2021-03-13/2021-03-13 16h 33m 21s.mp4: open failed: EROFS (Read-only file system)
Xiaomi Redmi 7A
java.io.FileNotFoundException: /storage/4DC6-1515/Android/media/MY_APP_PACKAGE_NAME_HERE/2021-03-12/2021-03-12 09h 18m 35s.mp4: open failed: EIO (I/O error)
Xiaomi Redmi Note 8T
java.io.FileNotFoundException: /storage/A018-ED55/Android/media/MY_APP_PACKAGE_NAME_HERE/2021-02-06/2021-02-06 17h 29m 59s.mp4: open failed: EIO (I/O error)
ZTE A2017G
java.io.FileNotFoundException: /storage/emulated/0/Movies/MY_APP_NAME_HERE/2021-03-26/2021-03-26 08h 27m 42s.mp4: open failed: ENOENT (No such file or directory)
So it mostly happens for Xiaomi devices, and mostly when recording to external micro SD Card (e.g. path is /storage/2A2C-40A4/***), though for built-in storage of phone (/storage/emulated/0/***) it also happens sometimes...
Versions of Android are different, from 6 (old) to 11 (newest), so it doesn't matter.
You can see that error is similar (starting with FileNotFoundException and file absolute path) but sometimes it changes at the end between
open failed: EROFS (Read-only file system)
open failed: ENOENT (No such file or directory)
open failed: EIO (I/O error)
open failed: EPERM (Operation not permitted)
Of course users don't send such error report everyday but still it happens often.
I don't have any idea why it happens. I can't reproduce this issue on my own devices (two Samsung, one Lenovo, one Huawei and one Xiaomi devices).
Maybe it happens because read/write time to storage was very slow or freezed (heavy load on it storage controller) at this point and Android (MediaRecorder) could not create an output video file for recording?
Any ideas or solutions?
p.s. full example of error:
java.io.FileNotFoundException:
/storage/5309-1D08/Android/media/MY_APP_PACKAGE_NAME_HERE/2021-04-10/2021-04-10
10h 17m 20s.mp4: open failed: EROFS (Read-only file system) at
libcore.io.IoBridge.open(IoBridge.java:485) at
java.io.RandomAccessFile.(RandomAccessFile.java:288) at
java.io.RandomAccessFile.(RandomAccessFile.java:151) at
android.hsm.HwMediaPermWrapper.setOutputFile(HwMediaPermWrapper.java:127)
at android.media.MediaRecorder.prepare(MediaRecorder.java:1028)
Caused by: java.io.FileNotFoundException: /RecordsKeeper/address/src/main/res/config.properties: open failed: ENOENT (No such file or directory)
I am getting the above error while I run my application. I am not able to load my config.properties file from config.java while I'm running my android application. Although it gets loaded and works fine when I run my library test cases using that config file.
And thank for your help.
I pushed some Jpgs on my Emulator, I run the SDCard Scan form the Media Provider tool,
so the pushed picture shows correctly in the Gallery.
I have an activity that queries the 'MediaStore.Images.Thumbnails'
The cursor works correctly, and it finds the path to the thumbnails.
But when I run the application the Logcat shows me that he is actually unable to open the files in the path:
02-14 13:45:08.015: E/BitmapFactory(931): Unable to decode stream: java.io.FileNotFoundException: /mnt/sdcard/DCIM/.thumbnails/1360429937982.jpg: open failed: ENOENT (No such file or directory)
02-14 13:45:08.046: E/BitmapFactory(931): Unable to decode stream: java.io.FileNotFoundException: /mnt/sdcard/DCIM/.thumbnails/1360503332805.jpg: open failed: ENOENT (No such file or directory)
02-14 13:45:08.076: E/BitmapFactory(931): Unable to decode stream: java.io.FileNotFoundException: /mnt/sdcard/DCIM/.thumbnails/1360525871295.jpg: open failed: ENOENT (No such file or directory)
02-14 13:45:08.095: E/BitmapFactory(931): Unable to decode stream: java.io.FileNotFoundException: /mnt/sdcard/DCIM/.thumbnails/1360525870839.jpg: open failed: ENOENT (No such file or directory)
02-14 13:45:08.135: E/BitmapFactory(931): Unable to decode stream: java.io.FileNotFoundException: /mnt/sdcard/DCIM/.thumbnails/1360525870385.jpg: open failed: ENOENT (No such file or directory)
Thank you very much your help very much appreciated
OK,
Problem solved, when I restarted the Emulator I asked to "Wipe User Data";
than again run DCard Scan form the Media Provider tool, and for the time being everything works fine.
Thanks anyway!!!