6

The problem: on android 4.x I get weird errors when downloading images:

07-23 10:31:05.961: E/XXX(32294): libcore.io.ErrnoException: open failed: ENOENT (No such file or directory) 
07-23 10:31:05.961: E/XXX(32294):  open failed: ENOENT (No such file or directory)

and sometimes:

07-23 10:31:06.133: W/System.err(32294): java.io.IOException: open failed: ENOENT (No such file or directory)
07-23 10:31:06.133: W/System.err(32294):    at java.io.File.createNewFile(File.java:940)
07-23 10:31:06.133: W/System.err(32294):    at com.XXX.XXX.JSON.Media.save(Media.java:55)
07-23 10:31:06.133: W/System.err(32294):    at com.XXX.XXX.JSON.Media.setFile(Media.java:78)
07-23 10:31:06.133: W/System.err(32294):    at com.XXX.XXX.ServerAccess.AsyncDownloadQueue$QueueMedia.isDone(AsyncDownloadQueue.java:257)
07-23 10:31:06.133: W/System.err(32294):    at com.XXX.XXX.ServerAccess.AsyncDownloadQueue.doInBackground(AsyncDownloadQueue.java:102)
07-23 10:31:06.133: W/System.err(32294):    at com.XXX.XXX.ServerAccess.AsyncDownloadQueue.doInBackground(AsyncDownloadQueue.java:1)
07-23 10:31:06.133: W/System.err(32294):    at com.XXX.Library.Threading.AsyncTask$2.call(AsyncTask.java:189)
07-23 10:31:06.133: W/System.err(32294):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
07-23 10:31:06.133: W/System.err(32294):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
07-23 10:31:06.133: W/System.err(32294):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
07-23 10:31:06.133: W/System.err(32294):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
07-23 10:31:06.133: W/System.err(32294):    at java.lang.Thread.run(Thread.java:856)
07-23 10:31:06.133: W/System.err(32294): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
07-23 10:31:06.141: W/System.err(32294):    at libcore.io.Posix.open(Native Method)
07-23 10:31:06.141: W/System.err(32294):    at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
07-23 10:31:06.141: W/System.err(32294):    at java.io.File.createNewFile(File.java:933)
07-23 10:31:06.141: W/System.err(32294):    ... 11 more

So the weird bit... this works on android 2.2 AND it works SOMETIMES with an image here and there on 4.x. The exact same download routine will download one file, but not others. Are there limitations when multithreading io access? Each thread is attached to a unique file so I don't think that's the issue; nothing is reading from a file that is being written to.

Oh and it shouldn't be a permission issue:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
Slynk
  • 527
  • 5
  • 9
  • Have you tried with different image formats? I know the gif was causing issues and android recommends against using it. – Nick Dec 03 '12 at 17:57
  • No gifs on our server. I never did figure this out but we ended up going a different route anyways. We stream in images as a resource and cache the http response (which, in turn, caches the file). Only problem is that it doesn't support https connections but oh well. – Slynk Dec 03 '12 at 22:12
  • Possibly related: [1](http://stackoverflow.com/questions/11620641/android-error-open-failed-enoent), [2](http://stackoverflow.com/questions/13051407/enoent-no-such-file-or-directory-when-trying-to-open-a-file-downloaded-from-ur) – Stephen Tetreault Mar 12 '13 at 19:11
  • Please post the code. – paulgavrikov Mar 18 '13 at 18:54
  • As I said in my previous comment, we went a different route so the code causing this issue is long gone. (This was posted 10 months ago.) – Slynk Mar 18 '13 at 22:04
  • You should check if the path to save image is hardcoded. SDCard path may be different from devices. – Krypton Mar 19 '13 at 08:18

0 Answers0