从android资产打开wav文件时出现FileNotFoundException

non*_*ned 2 android filenotfoundexception android-assets android-maven-plugin

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

String soundClipPath = "config/notification.wav"
AssetFileDescriptor afd = mContext.getAssets().openFd(soundClipPath);
int soundID = mSoundPool.load(afd, 1);
Run Code Online (Sandbox Code Playgroud)

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

  • 将wav文件放在res/raw文件夹中
  • 添加-0到maven android插件
  • 验证了文件结构,文件在那里工作.

使用上面的代码时,我们得到以下stacktrace:

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)
...
Run Code Online (Sandbox Code Playgroud)

尝试从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)
...
Run Code Online (Sandbox Code Playgroud)

有人可以帮我们解决这个奇怪的问题....

最好的祝福,

亨里克

小智 7

让我猜,您是否maven-jarsigner-plugin用于申请签名?而这个没有指定版本?maven-jarsigner-plugin大约四周前更新到版本1.3,现在我签署时我的应用程序做了一些奇怪的事情 - 在申请开始签名后我得到了像你这样的例外.我解决了它只是<version>1.2</version><artifactId>maven-jarsigner-plugin</artifactId>进入之后添加pom.xml.

我希望它对你也有帮助.