In my case, after trying many of the above solutions, I found an import that ended in .R
import android.os.Build.VERSION_CODES.R
Deleting it solved the problem. Somewhat similar to SmokeyTBear's answer above.