Same thing happened to me. And I was stuck for quite some time--what a shitty trick to play on someone for keeping Android Studio up-to-date. And simply rebuilding the project was NOT even close to working.
Apparently some changes were made to gradle that prevents older programs from compiling properly.
I had to create a new project and copy all my files into the new project. Yeah, it bites big hairy green ones, but it was what I had to do to get it to work.
I hope someone comes up with a better answer than this! (And I'd love to "talk" for a few minutes with the idiot that made this change! This is not the first time this has happened--nor the 2nd, the 3rd, 4th, etc etc.)
!!! NEW INFO !!!
Just started a new project and wham, this happened again. And it was using the master/design template. Yup, exactly as Android Studio produced the code there are errors in ItemListActivity.java
and other files because of the NonNull not importing correctly.
Sooooo, I went to the app build.gradle file and looked at all the dependency warnings. Why did the project generator use old dependencies? Hmmm. So I updated all the dependencies to use the latest. "Sync Now." Wow, it worked!
Here are the lines I updated:
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
Of course, you'll have to change the numbers to reflect the current versions.
Again, it boggles the imagination that straight-from-the-box templates have such glaring errors in them. Someday I'm going to take a journey to Mountainview and tie some shoelaces together.