java.io.FileNotFoundException: 这个文件不能作为文件描述符打开;它可能被压缩了 [英] java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
问题描述
我正在编写来自 android 的音板.问题是有些声音有效,有些则无效.这是我对不起作用的声音的回溯
i am programming a soundboard from android. the problem is that some sounds works, and some dont work. here is the traceback that i get for the sounds that doesnt work
05-31 13:23:04.227 18440 18603 W System.err: java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
05-31 13:23:04.227 18440 18603 W System.err: at android.content.res.AssetManager.openAssetFd(Native Method)
05-31 13:23:04.227 18440 18603 W System.err: at android.content.res.AssetManager.openFd(AssetManager.java:331)
05-31 13:23:04.227 18440 18603 W System.err: at com.phonegap.AudioPlayer.startPlaying(AudioPlayer.java:201)
05-31 13:23:04.227 18440 18603 W System.err: at com.phonegap.AudioHandler.startPlayingAudio(AudioHandler.java:181)
05-31 13:23:04.235 18440 18603 W System.err: at com.phonegap.AudioHandler.execute(AudioHandler.java:64)
05-31 13:23:04.235 18440 18603 W System.err: at com.phonegap.api.PluginManager$1.run(PluginManager.java:86)
05-31 13:23:04.235 18440 18603 W System.err: at java.lang.Thread.run(Thread.java:1096)
有什么想法吗?
推荐答案
在 assets 文件夹中打开压缩文件存在限制.这是因为未压缩的文件可以直接内存映射到进程虚拟地址空间,从而避免再次需要相同数量的内存进行解压缩.
There is a limitations on opening compressed files in the assets folder. This is because uncompressed files can be directly memory mapped into the processes virtual address space, therefore avoiding needing the same amount of memory again for decompression.
处理资产压缩Android Apps 讨论了一些处理压缩文件的技术.您可以使用未压缩的扩展名(例如 mp3
)诱使 aapt
不压缩文件,或者您可以手动将它们添加到 apk
无需压缩,而是让 aapt
完成工作.
Dealing with Asset Compression in Android Apps discusses some techniques in dealing with compressed files. You can trick aapt
into not compressing the file by using an extension that is not compressed (e.g. mp3
) or you can manually add them to the apk
without compression instead of getting aapt
to do the work.
这篇关于java.io.FileNotFoundException: 这个文件不能作为文件描述符打开;它可能被压缩了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!