Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am trying to play a custom sound res/raw/notification.mp3. It is ~91KB.

Here is my code

MediaPlayer.create(context, R.raw.notification).start();

Here is my error

04-14 15:57:55.387: ERROR/AndroidRuntime(233): android.content.res.Resources$NotFoundException: File res/raw/notification.mp3 from drawable resource ID #0x7f040000
04-14 15:57:55.387: ERROR/AndroidRuntime(233):     at android.content.res.Resources.openRawResourceFd(Resources.java:860)
04-14 15:57:55.387: ERROR/AndroidRuntime(233):     at android.media.MediaPlayer.create(MediaPlayer.java:641)
04-14 15:57:55.387: ERROR/AndroidRuntime(233):     at mypackage.MyActivity$1.onPostExecute(MyActivity.java:123)
04-14 15:57:55.387: ERROR/AndroidRuntime(233):     at android.os.AsyncTask.finish(AsyncTask.java:417)
04-14 15:57:55.387: ERROR/AndroidRuntime(233):     at android.os.AsyncTask.access$300(AsyncTask.java:127)
04-14 15:57:55.387: ERROR/AndroidRuntime(233):     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
04-14 15:57:55.387: ERROR/AndroidRuntime(233):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-14 15:57:55.387: ERROR/AndroidRuntime(233):     at android.os.Looper.loop(Looper.java:123)
04-14 15:57:55.387: ERROR/AndroidRuntime(233):     at android.app.ActivityThread.main(ActivityThread.java:4627)
04-14 15:57:55.387: ERROR/AndroidRuntime(233):     at java.lang.reflect.Method.invokeNative(Native Method)
04-14 15:57:55.387: ERROR/AndroidRuntime(233):     at java.lang.reflect.Method.invoke(Method.java:521)
04-14 15:57:55.387: ERROR/AndroidRuntime(233):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-14 15:57:55.387: ERROR/AndroidRuntime(233):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-14 15:57:55.387: ERROR/AndroidRuntime(233):     at dalvik.system.NativeStart.main(Native Method)
04-14 15:57:55.387: ERROR/AndroidRuntime(233): Caused by: java.io.FileNotFoundException: This file can not be opened as a file descriptor; it is probably compressed
04-14 15:57:55.387: ERROR/AndroidRuntime(233):     at android.content.res.AssetManager.openNonAssetFdNative(Native Method)
04-14 15:57:55.387: ERROR/AndroidRuntime(233):     at android.content.res.AssetManager.openNonAssetFd(AssetManager.java:426)
04-14 15:57:55.387: ERROR/AndroidRuntime(233):     at android.content.res.Resources.openRawResourceFd(Resources.java:857)
04-14 15:57:55.387: ERROR/AndroidRuntime(233):     ... 14 more

Same thing happens to an unrelated WAV file so it is probably not the MP3's problem.

What might be wrong? Should I uncompress the WAV/MP3? How?

like image 344
700 Software Avatar asked Nov 14 '22 00:11

700 Software


1 Answers

It turns out to be a problem with the NetBeans generated build scripts. I did a tutorial from scratch and it failed in NetBeans and worked in Eclipse. I suppose I will finally learn Eclipse. It is something I have been wanting to do at least as a comparison in hopes it would be less buggy, but I have not had the time. Well necessity is going to gave me the time now.

like image 101
700 Software Avatar answered Dec 23 '22 04:12

700 Software