title: package R does not exist....or does it?
body: <p>A few days ago, I accepted a contract from a returning client to make a few changes to his Android app over the course of the next few weeks. After getting the project source code from Github, I imported it into Android Studio (3.2) and noticed an error that I usually see pretty frequently but only for a short time during a Gradle sync: <code>error: package R does not exist</code>. Naturally, I shrugged my shoulders and ran 'Clean Project' and then 'Make Project.'</p>
  
  <p><strong><em>Nothing changed</em></strong></p>
  
  <p>Did a quick Google search and tried every 'solution' I could find. I tried every combination of "Make Project", "Make Module", "Clean Project", "Rebuild Project", "Sync Project with Gradle Files", "Sync with File System", "Invalidate Caches/Restart" imaginable. I restarted my laptop, updated SDK files, updated build tools, singled out each and every Gradle 'Implementation' line, and finally ended up uninstalling/reinstalling Android Studio as well as deleting all my IDE preferences just in case.</p>
  
  <p><strong><em>Still nothing</em></strong> </p>
  
  <p>Next, I created a new project and noticed that the generated <code>setContentView()</code> line had the same error referencing the generated layout file. <em>Wait.</em> An untouched new project is having the same error?!? I went ahead and pressed 'run' and the project compiled without any errors contrary to what the real-time inspections are saying. </p>
  
  <p>Switching back over to the original imported project, I tried running it and the compiler gives the same R package error. WHY?!?! There aren't any other errors, Android Lint runs cleanly, my Gradle implementations are recognized in the files, package names are all correct, and my AndroidManifest.xml file is perfectly fine.</p>
  
  <p>If you need to see my build.gradle files, AndoridManifest, or anything else, comment and let me know.</p>
  
  <p>Any ideas?</p>
  
  <h2>EDIT</h2>
  
  <p>Not a duplicate because as I mentioned, I've tried all of those solutions and none worked. I explained what I've tried, and why it's a unique situation.</p>
  
  <p>Compare the contents of your build folder to mine and you should notice the difference:
  <a href="https://i.stack.imgur.com/gGFOx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gGFOx.png" alt="enter image description here"></a></p>
  
  <p>Notice that the R folder in the upper image is marked differently? That's a working one. The lower image shows the broken project. These were taken moments apart.</p>
  
  <p><a href="https://i.stack.imgur.com/oekim.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oekim.png" alt="enter image description here"></a></p>