Some of these situations tend to pop up from time to time (for an instance with the generated class
R, where it ends up not being generated). The easiest way I have solved this in the past is to clean the project and rebuild it. And if that doesn’t work, press
File in the top menu and press “Invalidate caches and restart”. A second popup will appear, press “Invalidate caches and restart”. It may take a while as Android Studio needs to re-index and rebuild the project, but it solves most issues I have had.
The same happened to me and it was one of weirdest errors I ever got,
I used Butterknife in my project and I found out that if you define the views in private mode, you get this error
@BindView(R.id.tv_option_one) TextView tv_option_one; @BindView(R.id.tv_option_two) TextView tv_option_two;
@BindView(R.id.tv_option_one) private TextView tv_option_one; @BindView(R.id.tv_option_two) private TextView tv_option_two;
it mostly happens when Butterknife can’t find the view when you use bindView or the onClick annotation, and the worst part is that it shows errors everywhere except the place where they should be.
I ran into the same problem when I migrated to AndroidX. I ended up solving it by adding/updating the dependencies to
implementation 'com.github.bumptech.glide:glide:4.8.0-SNAPSHOT' kapt 'com.github.bumptech.glide:compiler:4.8.0-SNAPSHOT' kapt 'androidx.annotation:annotation:1.0.0-rc01'