1

So I'm trying to program a soundboard of me and my friends' voices, but the darn thing won't recognize R.raw.blahblahblah and keeps saying that raw cannot be resolved. Here's the bit of code that matters:

 package com.example.paksoundboard;

    import com.example.paksoundboard.R;
    import android.app.Activity;
    import android.media.MediaPlayer;
    import android.os.Bundle;
    import android.support.v4.app.NavUtils;
    import android.view.MenuItem;
    import android.view.View;
    import android.view.Window;



    public class SoundBoard extends Activity {
    public int guyt = Selection.whichMan();
    private MediaPlayer mp;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_sound_board);
    }


    public void John(View view){
    guyt = 1;
    }
    public void Ettore(View view){
    guyt = 2;
    }
    public void Phil(View view){
    guyt = 3;
    }
    public void Knox(View view){
    guyt = 4;
    }
    public void TJ(View view){
    guyt = 5;
    }
    public void yo(View view){
    mp.reset();
     switch (guyt) {
     case 1:  mp = MediaPlayer.create(getApplicationContext(),  com.example.paksoundboard.R.j.yo);
              break;
     case 2:  mp = MediaPlayer.create(getApplicationContext(), R.e.yo);
              break;
     case 3:  mp = MediaPlayer.create(getApplicationContext(),    com.example.paksoundboard.R.raw.t.yo);
              break;
     case 4:  mp = MediaPlayer.create(getApplicationContext(), R.k.yo);
              break;
     case 5:  mp = MediaPlayer.create(getApplicationContext(), R.raw.t.yo);
              break;
     }
     mp.prepare();
     mp.start();
    }

Any and all help would be greatly appreciated!!

Zankhna
  • 4,570
  • 9
  • 62
  • 103
  • R.raw.filename. No other formats or subfolders are supported – DroidBender Nov 21 '13 at 09:48
  • As you can see, I played around with the syntax of how the R.raw.whatever goes in, but anything after R. reads as cannot resolve. –  Nov 21 '13 at 09:49
  • @MartijnVanMierloo I realize the syntax, and I have set up the folders and files appropriately under the res/ folder. –  Nov 21 '13 at 09:49
  • The correct syntax is: res/raw/filename. If you have an error in your resources, the resources will not be build and your `R` is not going to be recognized in your code. – DroidBender Nov 21 '13 at 09:51
  • remove import com.example.paksoundboard.R; and then try to get id of songfile. – Pankaj Arora Nov 21 '13 at 09:53
  • put your file under: res/raw folder. Try by clean and build your project. There may be chaces of any error in res folder and that's why your `R.java` file is not generated and you will not be able to use it in your code. – Zankhna Nov 21 '13 at 09:53

1 Answers1

-1

just clean your project from eclipse by clicking on PROJECT->CLEAN... Make sure you wont have any compilation error at the time of cleaning other wise your R file will be deleted.Just comment the error lines and the uncomment them after cleaning and also delete this import import com.example.paksoundboard.R; and dont make sub folder in raw

Suhail Mehta
  • 5,514
  • 2
  • 23
  • 37