Question

In our android app we open wav file located in assets/config/notification.wav. To open and play the sound we are using the following code:

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

This has been working witout any problem for about a year now. Suddenly this has stopped working. We have not updated any dependencies between the builds. The only difference i can find is that the builds working is from last year. It works if we build the apk locally in netbeans but when we build the apk using hudson it doesn't work. I have tried the following with no luck:

  • Place the wav file in res/raw folder
  • Add -0 to maven android plugin
  • Verified the file structure and the file is there and working.

We get the following stacktrace when using the code above:

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)
...

And the following when trying to load from res/raw folder:

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)
...

Can someone please help us out with this strange problem....

Best regards,

Henrik

Was it helpful?

Solution

Let me guess, do you use maven-jarsigner-plugin for application signing? And this one has no version specified? Near four weeks ago maven-jarsigner-plugin was updated to version 1.3 and now it do something strange with my application when I sign it - after signing on application start I got exceptions like yours. I solved it simply adding <version>1.2</version> after <artifactId>maven-jarsigner-plugin</artifactId> in pom.xml.

I hope it helps you too.

OTHER TIPS

To play it from raw resources folder, which I would suggest you need something like this:

MediaPlayer mPlayer = MediaPlayer.create(PlayWorld.this, R.raw.notification);

And then you play around with the MediaPlayer. In the second exception you posted I see something weird: "File res/raw/notification.wav from drawable resource ID"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top