6

问题:在 android 4.x 上下载图像时出现奇怪的错误:

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)

而有时:

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

所以奇怪的一点......这适用于android 2.2,它有时适用于4.x上的图像。完全相同的下载例程将下载一个文件,但不会下载其他文件。多线程io访问时有限制吗?每个线程都附加到一个唯一的文件,所以我认为这不是问题;从正在写入的文件中没有读取任何内容。

哦,这不应该是权限问题:

<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" />
4

0 回答 0