Search code examples
androideclipsedevelopment-environmentr.java-file

android R class dont recognize the raw folder


Hi i want to play an mp3 backround music , i create the res\raw folder and put there an mp3 file and every thing is ok but: when i want to make an mediaplayer object R dont recognize my raw folder . I tryed to clean the project and reopen eclipse thanks for all the helpers :) here is the mainactivity:

    package com.example.whatsflagitis;

    import android.media.MediaPlayer;
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Menu;

    public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    MediaPlayer mysong=MediaPlayer.create(MainActivity.this, R.)
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

}


Solution

  • Try the below steps to resolve the issue,It worked for me:

    1. Cleaning the project and then building it again.
    2. Closing project and then opening it again.
    3. Going to Project Properties > Java Build Path > Tick Android Version Checkbox
    4. ensure no errors in XML files,Because errors in xml file Prevents the R.jave file to be created.
    5. try downloading the latest version of android SDK,if available.