-4

I am using the latest Android Studio but I can not find the location of R.java file.

Rob
  • 14,746
  • 28
  • 47
  • 65
  • try to rebuild the project, if that doesn't work goto file->invalidate caches/restart. that should fix. – madhu s Apr 16 '19 at 04:50
  • Possible duplicate of ["cannot resolve symbol R" in Android Studio](https://stackoverflow.com/questions/17054000/cannot-resolve-symbol-r-in-android-studio) – Zoe Apr 16 '19 at 10:45

1 Answers1

0

If your code doesn't resolve R class then it means the resource compilation or linking failed - check your logs for details. You should see an error from AAPT telling you why it failed.

If you just want to look at the contents of the R.java file instead, then it should be present in the app module, but in libraries AGP generates the R.jar (compiled bytecode) directly instead now.

If for some reason you want to write a custom task that does something with that file - DON'T. It is an intermediate file and should not be used by other tasks. Instead you can try using the R.txt file instead - it still contains all the resources with their IDs and is much easier to parse - and present in both library and the app modules.

Izabela Orlowska
  • 7,431
  • 2
  • 20
  • 33