Raunak Pandey
Raunak Pandey

Reputation: 370

cannot resolve symbol R.raw

enter image description here

In the above screenshot you can clearly see that I have created a raw folder with two files but when I do R.raw it says "cannot resolve raw".

here's all of my import statements:

package com.raunak.alarmdemo4.Activities;

import androidx.appcompat.app.AppCompatActivity;
import android.annotation.SuppressLint;
import android.content.ContentValues;
import android.content.pm.ActivityInfo;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import com.arbelkilani.clock.Clock;
import com.ebanx.swipebtn.OnStateChangeListener;
import com.ebanx.swipebtn.SwipeButton;
import com.raunak.alarmdemo4.HelperClasses.AlarmsDBhelperClass;
import com.raunak.alarmdemo4.R;
import java.io.IOException;
import java.util.Calendar;
import static com.raunak.alarmdemo4.R.*;

Upvotes: 1

Views: 669

Answers (2)

Waqar UlHaq
Waqar UlHaq

Reputation: 6422

Just make sure you have imported correct Resource

import your.package.name.R

not like or similar

import android.R

After that

Clean & build

Upvotes: 1

Elio Lako
Elio Lako

Reputation: 1351

Try cleaning your project and building again. If this not work :

  1. Remove the import for the R.symbol, because probably you have imported R.class in your file, then click on the imported file and press ALT + Enter.
  2. If this also doesn't work then access it like this : your.project.package.R.raw .file_name
  3. Also try to remove the capital letter from the name of your audio.

Upvotes: 2

Related Questions