title: Could not find method android() for arguments when building Android project from gradle
body: <p>I have an gradle-based Android project with 4 submodules - two libraries and two applications. I was trying to simplify the build.gradle files of each submodule by moving some of of the shared code/configurations to the top level build.gradle file and use <code>subprojects {}</code> to make that code available to each submodule.</p>
  
  <p>The file system structure looks like this:</p>
  
  <pre><code>Root
   |- App1/
   |- App2/
   |- Lib1/
   |- Lib2/
   |- build.gradle
   |- settings.gradle
  </code></pre>
  
  <p>The problem is that if I add an <code>android {}</code> section to the subprojects then gradle tasks fail. For example, this is my top-level build.gradle file:</p>
  
  <pre><code>subprojects { project -&gt;
    android {
      buildToolsVersion "20.0.0"
    }
  }
  </code></pre>
  
  <p>Running gradle returns this:</p>
  
  <blockquote>
    <p>What went wrong:
    A problem occurred evaluating root project 'android'.
    Could not find method android() for arguments [build_7dngpra6ldok366maq0on77r7e$_run_closure3_closure5@43d95624] on root project 'android'.</p>
  </blockquote>
  
  <p>I searched for similar posts and some people suggest adding the line <code>apply plugin: 'android'</code> to each subproject in order to expose the missing <code>android()</code> method that gradle is complaining about. However, that solution doesn't work for me because it would effectively add that line to library project, which require <code>apply plugin: 'android-library'</code> instead.</p>
  
  <p>Is there a way to use <code>android {}</code> inside of <code>subprojects {}</code> when you have apps and libraries in the same project?</p>