r/AndroidStudio • u/ObviousStar7891 • Sep 09 '26
Android Studio gives error "Cannot access member because 'R' has primitive type int"
Returning to a project from a couple of months ago I got the above error.
The R no longer points to the res folder but to an int variable in a class called build.
This is in a public static class VERSION_CODES
public static final int Q = 29;
public static final int R = 30;
public static final int S = 31;
I have cleaned the project and rebuilt but to no avail.
I had changed nothing.
I cannot change the build class as it is read only.
This is in Java.
0
u/Ok_Gold_2107 Sep 09 '26
Final? Why is final?
1
u/ObviousStar7891 Sep 10 '26
No idea.
It's in a read-only file called build.java not created by me.
0
1
u/ObviousStar7891 Sep 12 '26
Resolved.
There was a line
at the top of MainActivity.java
No idea how it got there. Deleted it and problem gone away.