Hello,

I am trying to make an app that simply plays an mp3 file when you
click on a button.  I've based my code off the API Demos from the
android website, and I've been scouring various Android developer
boards but all the solutions are still resulting in the same problem.

When you click on the button this code should be executed:

    private void playAudio(Integer media){
        MediaPlayer m = MediaPlayer.create(this, R.raw.b);
        m.start();
    }

When the program gets executed and I click on the button the program
crashes.  All I've been able to determine from the stack trace is
that:
1 - The resource file cannot be found
or
2 - I am not able to open the file descriptor for some reason (it's
compressed?)

Here is the stack trace I am getting from logcat:
E/AndroidRuntime( 1425): Uncaught handler: thread main exiting due to
uncaught
exception
E/AndroidRuntime( 1425): java.lang.RuntimeException: Unable to start
activity ComponentInfo{org.me.demogo/org.me.demogo.DemoGoPlayer}:
android.content.res.Resources$NotFoundException: File res/raw/a.mp3
from drawable resource ID
#0x7f040000
E/AndroidRuntime( 1425):        at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2268)
E/AndroidRuntime( 1425):        at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2284)
E/AndroidRuntime( 1425):        at android.app.ActivityThread.access
$1800(ActivityThread.java:
112)
E/AndroidRuntime( 1425):        at android.app.ActivityThread
$H.handleMessage(ActivityThread.java:
1692)
E/AndroidRuntime( 1425):        at android.os.Handler.dispatchMessage
(Handler.java:
99)
E/AndroidRuntime( 1425):        at android.os.Looper.loop(Looper.java:
123)
E/AndroidRuntime( 1425):        at android.app.ActivityThread.main
(ActivityThread.java:
3948)
E/AndroidRuntime( 1425):        at
java.lang.reflect.Method.invokeNative(Native
Method)
E/AndroidRuntime( 1425):        at java.lang.reflect.Method.invoke
(Method.java:
521)
E/AndroidRuntime( 1425):        at com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:
782)
E/AndroidRuntime( 1425):        at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
540)
E/AndroidRuntime( 1425):        at dalvik.system.NativeStart.main
(Native
Method)
E/AndroidRuntime( 1425): Caused by: android.content.res.Resources
$NotFoundException: File res/raw/a.mp3 from drawable resource ID
#0x7f040000
E/AndroidRuntime( 1425):        at
android.content.res.Resources.openRawResourceFd(Resources.java:
814)
E/AndroidRuntime( 1425):        at android.media.MediaPlayer.create
(MediaPlayer.java:
550)
E/AndroidRuntime( 1425):        at org.me.demogo.DemoGoPlayer.playAudio
(DemoGoPlayer.java:
29)
E/AndroidRuntime( 1425):        at org.me.demogo.DemoGoPlayer.onCreate
(DemoGoPlayer.java:
25)
E/AndroidRuntime( 1425):        at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1123)
E/AndroidRuntime( 1425):        at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2231)
E/AndroidRuntime( 1425):        ... 11
more
E/AndroidRuntime( 1425): Caused by: java.io.FileNotFoundException:
This file can not be opened as a file descriptor; it is probably
compressed
E/AndroidRuntime( 1425):        at
android.content.res.AssetManager.openNonAssetFdNative(Native
Method)
E/AndroidRuntime( 1425):        at
android.content.res.AssetManager.openNonAssetFd(AssetManager.java:
412)
E/AndroidRuntime( 1425):        at
android.content.res.Resources.openRawResourceFd(Resources.java:
811)
E/AndroidRuntime( 1425):        ... 16 more

Thank you,
CS

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to