title: Why does Android Studio ignore classes added through main.java.srcDirs?
body: <p>I have added a task to gradle to generate classes at compile time. Then in the android configuration I have added the following to make them compilable:</p>
  
  <pre><code>def extraSrcDir = new File("$buildDir.absolutePath/generatedAutoGradha")
  
  android {
      sourceSets {
          main.java.srcDirs += extraSrcDir.absolutePath
      }
  }
  </code></pre>
  
  <p>This works and the code compiles, I can use <code>import com.generated.stuff;</code> etc, but despite the compilation working Android Studio flags all the usages of the class as wrong code. In fact, the Android aware project structure doesn't show the generated code despite the files being there.</p>
  
  <p><a href="https://i.stack.imgur.com/jFBK3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jFBK3.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/DxYdv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DxYdv.png" alt="enter image description here"></a></p>
  
  <p>How can I make Android Studio recognise the generated directory?</p>