java.io.FileNotFoundException:此文件不能打开的文件描述符;它可能是COM pressed文件、io、java、FileNotFoundException

2023-09-12 23:38:26 作者:逃不开他是身体扩散的癌

我编程,从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)

什么想法?

推荐答案

目前在资产文件夹打开COM pressed文件的限制。这是因为,pssed uncom $ P $文件可以直接存储器映射到进程的虚拟地址空间,从而避免再次需要用于DECOM pression相同的内存量。

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.

与资产的COM $ P处理$ pssion在Android应用讨论在处理COM pressed文件的一些技巧。你可以欺骗 AAPT 成不COM $ P $使用分机不是COM pressed(如 MP3 ),也可以手动添加获取到 APK 无COM pression代替 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.