Hello, I am getting a resource not found exception when I attempt to create a MediaPlayer via MediaPlayer.create. The full text of the exception is "android.content.res.Resources $NotFoundException:File res/raw/dice_land.ogg from drawable resource ID #7f030000"
I have done a google search and found that a few others have had the same problem, but solutions are scarce. Here is what I have verified: *The sound file is in the res/raw folder, and is named correctly. *The build system is finding it, because it is correctly generating a resource ID for it in R.java. *The apk file, when opened as a ZIP file, contains the res/raw directory and that directory contains my dice_land.ogg sound file. *That sound file plays in my media player on my desktop pc and (when I put it on my SD card) plays using the music player app on my phone, so the file is not corrupt. *Other than the sound, the application runs fine, and other resources like the button and the main LinearLayout and the applicaiton name are getting loaded with no trouble. *It does not matter if the file is .ogg, .wav, or .mp3. I have tried all 3, and always get identical exception (with the file extension different, obviously) I have tried creating the MediaPlayer in the onCreate method, and in a button OnClickListener (the current version). Identical results. I am building in debug mode, so the keystore is the default.keystore from the android sdk. I am using android_sdk_r05 tools. I am running NetBeans 6.8 with the android development plugin NBAndroid v 1.0. The target platform is the MyTouch 3g running the factory configuration, which is Android 1.6. I have zipped up my NetBeans project in its entirety, and put it in google docs. You all can access it here: https://docs.google.com/leaf?id=0B72czU3VsdcaOGNmZDBlMjktMGZkMS00OTc4LThhNTQtMDJjMzM2YjUwMGI4&hl=en For those not inclined to that much detail, here is the source code: package com.europasw.soundcheck; import android.app.Activity; import android.app.AlertDialog; import android.media.MediaPlayer; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class SoundCheck extends Activity { MediaPlayer mp = null; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); this.setContentView(R.layout.main); Button rollButton = (Button) this.findViewById(R.id.rollButton); rollButton.setOnClickListener(rollButtonClicked); } OnClickListener rollButtonClicked = new OnClickListener() { public void onClick(View v) { try { if (mp == null) { mp = MediaPlayer.create(v.getContext(), R.raw.dice_land); } if (mp != null) { mp.reset(); mp.prepare(); mp.start(); } else { MessageBox("Couldn't create MediaPlayer"); } } catch (Exception x) { // I always end up here. MessageBox("Exception: " + x); } } }; @Override public void onDestroy() { if (mp != null) { mp.release(); } super.onDestroy(); } void MessageBox(String msg) { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(msg); builder.setPositiveButton("OK", null); AlertDialog d = builder.show(); } } And here is the contents of R.java: /* AUTO-GENERATED FILE. DO NOT MODIFY. * * This class was automatically generated by the * aapt tool from the resource data it found. It * should not be modified by hand. */ package com.europasw.soundcheck; public final class R { public static final class attr { } public static final class id { public static final int rollButton=0x7f050000; } public static final class layout { public static final int main=0x7f020000; } public static final class raw { public static final int dice_land=0x7f030000; } public static final class string { public static final int app_name=0x7f040000; } } Thanks for your time. Any help would be greatly appreciated. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

