title: FileProvider authority in android library project
body: <p>In a <a href="https://github.com/jonasrottmann/realm-browser/issues/20" rel="noreferrer">library project</a> I'm using a <a href="https://developer.android.com/reference/android/support/v4/content/FileProvider.html" rel="noreferrer">FileProvider</a> with my libraries applicationId as its authority. Now when somebody uses this library e.g. in two flavors of his app, the second one will not install because of conflicting FileProviders.</p>
  
  <p><strong>Goal</strong></p>
  
  <p>Being able to define a unique authority for my libraries FileProvider for each variant of an application. </p>
  
  <p><strong>First Approach</strong></p>
  
  <p>Im appending a random int to the authority, which works just fine.</p>
  
  <p><em>build.gradle</em></p>
  
  <pre><code>static def generateContentProviderAuthority() {
      Random random = new Random()
      return new StringBuilder()
              .append("application.id.of.my.library")
              .append(".fileprovider")
              .append(String.valueOf(random.nextInt(100000)))
              .toString()
  }
  
  
  defaultConfig {
      ...
      manifestPlaceholders= [contentProviderAuthority: generateContentProviderAuthority()]
  }
  </code></pre>
  
  <p><em>Manifest</em></p>
  
  <pre><code>&lt;provider
      android:name=".helper.FileProvider"
      android:authorities="${contentProviderAuthority}"
      android:exported="false"
      android:grantUriPermissions="true"&gt;
      &lt;meta-data
          android:name="android.support.FILE_PROVIDER_PATHS"
          android:resource="@xml/filepaths"/&gt;
  &lt;/provider&gt;
  </code></pre>
  
  <p>But now the manifest changes every build, which messes with instant run and stuff...</p>
  
  <p><strong>Solution</strong></p>
  
  <p>Is it possible to get the exact applicationId of the application which uses the library in my libraries build.gradle?</p>