title: Crashlytics not finding API Key in crashlytics.properties at runtime
body: <p>I'm currently implementing the API Key switching script suggested <a href="https://stackoverflow.com/a/25704532/4107115">here</a>, except with build types instead of flavors. My build.gradle looks like this:</p>
  
  <pre><code>...
  buildTypes {
      debug {
          ...
          set("crashlyticsApiKey", "API_KEY_1")
          set("crashlyticsApiSecret", "API_SECRET_1")
      }
      release {
          ...
          set("crashlyticsApiKey", "API_KEY_2")
          set("crashlyticsApiSecret", "API_SECRET_2")
      }
  }
  ...
  productFlavors{...}
  ...
  File crashlyticsProperties = new File("${project.projectDir.absolutePath}/crashlytics.properties")
  
  applicationVariants.all { variant -&gt;
      variant.productFlavors.each { flavor -&gt;
          def variantSuffix = variant.name.capitalize()
          def generateResourcesTask = project.tasks.getByName("crashlyticsGenerateResources${variantSuffix}")
          def generatePropertiesTask = task("crashlyticsGenerateProperties${variantSuffix}") &lt;&lt; {
              Properties properties = new Properties()
              println "...copying apiKey for ${variant.name}"
              properties.put("apiKey", variant.buildType.crashlyticsApiKey)
              println "...copying apiSecret for ${variant.name}"
              properties.put("apiSecret", variant.buildType.crashlyticsApiSecret)
              properties.store(new FileWriter(crashlyticsProperties), "")
          }
          generateResourcesTask.dependsOn generatePropertiesTask
          def cleanResourcesTask = project.tasks.getByName("crashlyticsCleanupResourcesAfterUpload${variantSuffix}")
          cleanResourcesTask.doLast {
              println "...removing crashlytics.properties"
              crashlyticsProperties.delete()
          }
      }
  }
  ...
  </code></pre>
  
  <p>The gradle file builds successfully, and crashlytics.properties updates with the correct information according to the build type. This method of using crashlytics.properties was suggested <a href="https://plus.google.com/+AntonioBertucci/posts/S9krjvXfgfm" rel="noreferrer">here</a>, and appears to work without any other updates other than the inclusion of dependencies in the gradle file. However, when <code>Crashlytics.start(this)</code> is called from the main activity, I get a runtime exception:</p>
  
  <pre><code>java.lang.RuntimeException: Unable to create application com.lookout.LookoutApplication: java.lang.IllegalArgumentException: Crashlytics could not be initialized, API key missing from AndroidManifest.xml. Add the following tag to your Application element
  &lt;meta-data android:name="com.crashlytics.ApiKey" android:value="YOUR_API_KEY"/&gt;
  </code></pre>
  
  <p>Stripping it down to a static crashlytics.properties file (i.e. removing the dynamic script in the gradle file and just having one apiKey and apiSecret in crashlytics.properties) produces the same error, even though it builds successfully.</p>
  
  <p>Is there some change to the AndroidManifest or the build.gradle file I should be making to point it towards crashlytics.properties?</p>