title: Android Studio two flavors with different manifest files
body: <p>I'm having issues with defining two different manifest files for my flavors in Android Studio. This is my current project structure:</p>
  
  <p><img src="https://i.stack.imgur.com/xtNzP.jpg" alt="Current project structure"></p>
  
  <p>The <code>AndroidManifest.xml</code> in the <code>free</code> flavor looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="se.example.package"&gt;
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>The <code>AndroidManifest.xml</code> in the <code>main</code> flavor has no uses-permissions, but contains the rest of the manifest code that is shared between all flavors.</p>
  
  <p>The <code>AndroidManifest.xml</code> in the <code>pro</code> flavor looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="se.example.package"&gt;
      &lt;uses-permission android:name="com.android.vending.CHECK_LICENSE" /&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>build.gradle defines the two flavors like </p>
  
  <pre><code>productFlavors {
      free {
          applicationId 'se.example.package.free'
          minSdkVersion 14
          targetSdkVersion 21
          versionCode 1
          versionName '1.0'
      }
      pro {
          minSdkVersion 14
          applicationId 'se.example.package.pro'
          targetSdkVersion 21
          versionCode 2
          versionName '1.1'
      }
  }
  </code></pre>
  
  <p>The result that I am expecting is that the different flavors defines different uses-permissions. <strong>This is not the case.</strong> The result is currently that the both flavors only defines the <code>&lt;uses-permission android:name="com.android.vending.CHECK_LICENSE" /&gt;</code> as defined in <code>AndroidManifest.xml</code> in the pro flavor. </p>
  
  <p>I have tried:</p>
  
  <ul>
  <li>Clean project </li>
  <li>Rebuild project</li>
  <li>Restart Android Studio</li>
  <li>Sync gradle</li>
  </ul>
  
  <p>But without success. How am I to fix this? Any help is appreciated.</p>
  
  <p><strong>EDIT 1</strong></p>
  
  <p>I changed the location of each flavors <code>AndroidManifest.xml</code> file from each of the <code>res</code> folders to <code>free</code> and <code>pro</code> folder. The result of this:</p>
  
  <ol>
  <li>Pro flavor shows Licence permission as expected.</li>
  <li>Free flavor shows permissions from both <code>AndroidManifest.xml</code>
  files, License and network permissions (Should be only network)</li>
  </ol>
  
  <p>This feels like an issue of project structure. What to make of this?</p>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>I pulled the merge reports as Commonsware hinted, these are the reports regarding <code>uses-permissions</code></p>
  
  <p>Free:</p>
  
  <pre><code>uses-permission#com.android.vending.CHECK_LICENSE
  ADDED from qwknoteGIT:licencing-library:unspecified:26:5
      android:name
          ADDED from qwknoteGIT:licencing-library:unspecified:26:22
  </code></pre>
  
  <p>Pro:</p>
  
  <pre><code>uses-permission#com.android.vending.CHECK_LICENSE
  MERGED from qwknoteGIT:licencing-library:unspecified:26:5
  </code></pre>