Today I faced the same problem, but no answer here, nor comment, helped me.
At the end there were 2 problems, probably one caused by the other...
My antivirus (Avast) detected "threat" from one SDK file... so probably my Android Studio thought there was no inclusion of AppCompat library in my "build.graddle" file and added a second one automatically. It looked like this:
compile "com.android.support:appcompat-v7:21.0.+"
compile "com.android.support:appcompat-v7:21.+"
So I deleted one of them and i got R class back, but "appt" error was still there.
- Aparently my dear Avast took some exe's from SDK folder, so I started "SDK Manager". In the manager, the "SDK Compile Tools" I was using (2.1.1 I think) was unckecked (maybe failed at checksum comarison), so I re-installed it.
And VOILA!, It worked and now I'm happy.