android 打开file not found,从android资源中打开wav文件时出现FileNotFoundException(FileNotFoundException when openi...

从android资源中打开wav文件时出现FileNotFoundException(FileNotFoundException when opening wav file from android assets)

在我们的android应用程序中,我们打开位于assets / config / notification.wav中的wav文件。 要打开和播放声音,我们使用以下代码:

String soundClipPath = "config/notification.wav"

AssetFileDescriptor afd = mContext.getAssets().openFd(soundClipPath);

int soundID = mSoundPool.load(afd, 1);

大约一年以来,这一直在解决任何问题。 突然间,这已停止工作。 我们没有更新构建之间的任何依赖关系。 唯一的区别是我能找到的是这个版本的工作是从去年开始的。 如果我们在NetBeans本地构建apk,但是当我们使用hudson构建apk时,它不起作用。 我已经尝试了以下,但没有运气:

将wav文件放在res / raw文件夹中

将-0添加到maven android插件

验证了文件结构并且文件在那里并正在工作。

使用上面的代码时,我们得到以下堆栈跟踪:

java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed

at android.content.res.AssetManager.openAssetFd(Native Method)

at android.content.res.AssetManager.openFd(AssetManager.java:331)

...

当试图从res / raw文件夹加载时出现以下情况:

android.content.res.Resources$NotFoundException: File res/raw/notification.wav from drawable resource ID #0x7f040000

at android.content.res.Resources.openRawResourceFd(Resources.java:981)

at android.media.SoundPool.load(SoundPool.java:191)

...

你可能感兴趣的:(android,打开file,not,found)