0

In Android Studio, code in my MainActivity suddenly started showing all kinds of errors (red underlines all over the place). But the code is fine. It compiles and runs without problems. This just started happening all of a sudden. The highlighted errors all seem to be related to the context of the activity. For example:

Context context = this;
findViewById
registerReceiver

I cleared the cache and restarted Android Studio but this didn't help. I also tried deleted all the files in the build directories.

Johann
  • 27,536
  • 39
  • 165
  • 279
  • how about clean and build? – Rod_Algonquin Mar 02 '16 at 16:05
  • Did that too. I updated my build.gradle to use a more recent version in order to use vector graphics. Thought that this might have been the problem, so I reverted to the older version. Have a feeling this is a gradle issue. Came across a similiar post: http://stackoverflow.com/questions/34078404/cannot-resolve-findviewbyid-in-appcompatactivity – Johann Mar 02 '16 at 16:10
  • did you update android studio?? – Rod_Algonquin Mar 02 '16 at 16:13
  • Reinstall android studio? – Luca Ziegler Mar 02 '16 at 16:19
  • Solved the problem by installing a Gradle version that matched the version I switched to. There appears to be a problem with Gradle syncing its file when you change the version in build.gradle. – Johann Mar 02 '16 at 16:21

0 Answers0