You need to import the correct R
— specifically, the one for your project. This is based on what's in your project's manifest. If your manifest declares the project's package to be com.example.my_project
then you need to import com.example.my_project.R;
.
If your activity is already in the project's package, then you do not need to import R
. However, you specifically need to not import android.R
.
The error message may also be caused by a missing R.java. This can happen if errors in your resources prevents R.java from being generated. You should check that there are no errors in any of your resource files.