title: How to build Android gradle project that contains modules with different compileSdkVersion, targetSdkVersion, and minSdkVersion?
body: <p>My Android library project is made up of four modules:</p>
  
  <ul>
  <li>project
  
  <ul>
  <li>base</li>
  <li>factory</li>
  <li>v14</li>
  <li>v18</li>
  </ul></li>
  </ul>
  
  <p>Here's a screenshot of this setup from IntelliJ:</p>
  
  <p><img src="https://i.stack.imgur.com/jJe5N.png" alt="modules"></p>
  
  <p>My modules utilize very specific Android SDK level settings:</p>
  
  <ul>
  <li>base
  
  <ul>
  <li><code>compileSdkVersion 19</code></li>
  <li><code>minSdkVersion 14</code></li>
  <li><code>targetSdkVersion 19</code></li>
  </ul></li>
  <li>factory
  
  <ul>
  <li><code>compileSdkVersion 19</code></li>
  <li><code>minSdkVersion 14</code></li>
  <li><code>targetSdkVersion 19</code></li>
  </ul></li>
  <li>v14
  
  <ul>
  <li><code>compileSdkVersion 17</code></li>
  <li><code>minSdkVersion 14</code></li>
  <li><code>targetSdkVersion 17</code></li>
  </ul></li>
  <li>v18
  
  <ul>
  <li><code>compileSdkVersion 18</code></li>
  <li><code>minSdkVersion 18</code></li>
  <li><code>targetSdkVersion 18</code></li>
  </ul></li>
  </ul>
  
  <p>As newer versions of Android are released, the base and factory modules can have their <code>compileSdkVersion</code> and <code>targetSdkVersion</code> levels follow along. However, v14 and v18 both absolutely can't follow suit with this.</p>
  
  <p>My modules depend on each other in very specific ways:</p>
  
  <ul>
  <li>base
  
  <ul>
  <li>does not depend on any other module</li>
  </ul></li>
  <li>factory
  
  <ul>
  <li>depends on base, v14, and v18</li>
  </ul></li>
  <li>v14
  
  <ul>
  <li>depends on base</li>
  </ul></li>
  <li>v18
  
  <ul>
  <li>depends on base</li>
  </ul></li>
  </ul>
  
  <p>So when I go to build my project, I receive this error:</p>
  
  <pre><code>Error:Gradle: Execution failed for task ':v14:processReleaseManifest'.
  &gt; Manifest merging failed. See console for more info.
  </code></pre>
  
  <p>When building via terminal using <code>./gradlew build --stacktrace</code>, I get a little bit more information:</p>
  
  <pre><code>:v14:processReleaseManifest
  [/blahblah/project/v14/build/exploded-aar/blahblah/base/unspecified/AndroidManifest.xml:2] Main manifest has &lt;uses-sdk android:targetSdkVersion='17'&gt; but library uses targetSdkVersion='19'
  :v14:processReleaseManifest FAILED
  </code></pre>
  
  <p>And here's my v14 <code>AndroidManifest.xml</code> file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest package="com.example.v14"&gt;
  
      &lt;application /&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>(My base <code>AndroidManifest.xml</code> file is nearly exactly identical)</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest package="com.example"&gt;
  
      &lt;application /&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>This error doesn't make very much sense to me. First of all, I don't specify version levels in any of my four different <code>AndroidManifest.xml</code> files (and I instead let those values be inherited through my four different <code>build.gradle</code> files).</p>
  
  <p>Secondly, I don't have a "Main manifest". The base module is probably the closest thing I have to that, and so how exactly the v14 module ended up as the "Main manifest" I find pretty confusing.</p>
  
  <p>Finally, if this project setup isn't possible, then I'm shocked. This module configuration is absolutely trivial to set up in an Eclipse-style project. It's how I've been building the library for months now.</p>
  
  <p>By the way, my end goal is for this to all compile down to a single <code>.jar</code> file, which my current Eclipse-style project can do. It's just that I'm trying to completely migrate over to gradle and not be left behind on a sinking ship...</p>
  
  <p>Any ideas? If necessary, I can post my various gradle files (<code>build.gradle</code>, <code>settings.gradle</code>...). Just trying to avoid completely overloading this post.</p>
  
  <h2>Edit (May 27th, 2014)</h2>
  
  <p>Added a screenshot of my module configuration to the beginning of this post.</p>